Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ676
Page ↗
Q676FWASIC interview problem

Sort intervals by start and end

TechniquesSortingStructComposite key
DifficultyEasy
TopicArrays
LanguageSystemVerilog
Requirements3 checkpoints
01

Problem

Sort a queue of address intervals by start address, then by end address when starts are equal.

Example input and output

Use this case to check your interpretation
Input
intervals = [(4, 8), (1, 5), (1, 3)]
Output
[(1, 3), (1, 5), (4, 8)]
Explanation

The start value is the primary key and the end value breaks ties deterministically.

02

Requirements (3)

  • Sort in ascending unsigned address order.
  • Use end_addr only as the tie-breaker.
  • Do not combine fields into an overlapping arithmetic key.