Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
    • Datatype and Bit Puzzles
    • Fork Join Puzzles
    • Queue and Array Puzzles
      • Queue Mutation Plus Dynamic Resize
      • Queue Assignment Copies by Value
      • Pop from Empty Queue
      • Dynamic Array Resize with Class Handles
      • Associative Array Iteration Order
      • Locator Methods Return New Queues
    • String and Casting Puzzles
    • SystemVerilog Language Puzzles: Tricky Q&A
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • Interview Prep: Puzzle Rounds5
  • DV Puzzle Cheatsheet
Loading lesson

‹Queue and Array Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. SystemVerilog Language Puzzles
  4. Queue and Array Puzzles
  5. Pop from Empty Queue

VLSI DV Interview Puzzles · All levels

Pop from Empty Queue

What values are returned by `pop_front` and `pop_back` on an empty queue?

On this page

    Puzzle

    Difficulty: Medium · Puzzle 3 of 6 · Topic: Queue and Array Puzzles

    What values are returned by `pop_front` and `pop_back` on an empty queue?

    Code

    p3.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    module p3;
      int q[$];
      int a, b;
      initial begin
        a = q.pop_front();
        b = q.pop_back();
        $display("a=%0d b=%0d size=%0d", a, b, q.size());
      end
    endmodule

    Hint

    SV returns default value of element type when popping from an empty queue.

    Step-by-step solution

    Diagram
    1) Queue starts empty.
    2) `pop_front()` returns default `int` value 0 when queue is empty.
    3) `pop_back()` on still-empty queue also returns 0.
    4) Queue size remains 0.

    Answer

    Answer: a=0, b=0, size=0

    Why candidates get it wrong

    Some interviewees expect runtime fatal behavior and skip default-value semantics.

    Interviewer follow-up

    How would behavior differ for `string q[$]` when popping empty?

    Related topics

    • Back to Queue and Array Puzzles

    • SystemVerilog Language Puzzles section

    Previous

    19 / 210

    Next: Dynamic Array Resize with Class Handles

    Up next

    Up nextDynamic Array Resize with Class Handles

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Queue Mutation Plus Dynamic Resize
    • Associative Array Iteration Order
    • Locator Methods Return New Queues