ORIGINAL COMPANY-CONTEXT PRACTICE
Search a sorted service-range table
Original practice scenario inspired by Deutsche Telekom AG's public business context; this is not a reported interview question or a description of its internal systems. A synthetic coverage checker stores nonoverlapping sorted integer address ranges with a service label. Explain a logarithmic lookup for an address, and how you would test gaps and exact endpoints.
Written for independent practice using company context; this is not a verified question from a company interview.
A REASONED APPROACH
Model answer.
Binary-search for the range with the greatest start not exceeding the address, then verify that the address is within that range's end. Finding a predecessor alone does not prove coverage.
Work through it
- Specify inclusive or half-open endpoints and validate sorted, nonoverlapping ranges when loading configuration. Reject ambiguous overlaps rather than selecting an arbitrary service.
- Use a half-open search over starts to locate the first start greater than the address, then inspect its predecessor if one exists.
- Test empty configuration, an address before the first range, both boundaries, an internal gap, and an address after the final range. Include a single-address range.
Tradeoffs to discuss
- Static sorted arrays offer compact logarithmic reads; frequent range updates may favor an ordered structure with stronger update support.
Common pitfalls
- Returning the predecessor label without checking its end incorrectly fills coverage gaps.
- Mixing endpoint conventions creates off-by-one errors at neighboring ranges.