Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Implement and verify a bounded queue

Hardware interview practice

Implement and verify a bounded queue

MediumData StructuresPYTHON

Implement a fixed-capacity FIFO with O(1) push, pop, and peek, then briefly explain how you would verify its boundary and wraparound behavior.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
capacity=3; push(10), push(20), push(30), push(99), pop(), push(40)
Expected output
push(99) reports overflow and changes no state; pop returns 10; final queue is [20, 30, 40]

The failed overflow leaves the full queue intact, then the final push wraps the circular tail into the slot cleared by pop.

What to cover

Requirements

  1. Reject nonpositive capacity, overflow, and pop or peek underflow.
  2. Use a circular array with explicit head, tail, and size state.
  3. Clear a popped slot so the queue does not retain stale object references.
  4. Describe directed wraparound checks and a seeded randomized comparison against collections.deque.
asic.fyi · Learn silicon end to end.info@asic.fyi