Skip to question
SystemVerilogDesignVerificationFirmwareArchitectureASIC Interview Questions→
/Interview questions/Associative-array traversal

Q195·Free·SystemVerilog

Associative-array traversal

Difficulty
Easy
Topic
Data Structures
Language
SV
Interview prompt

Question

What key values are displayed?

Provided context

Code to inspect

int aa[int];
int k;
initial begin
  aa[10] = 1; aa[-2] = 2; aa[5] = 3;
  void'(aa.first(k)); $write("%0d ", k);
  void'(aa.next(k));  $display("%0d", k);
end
Choose one

Answer choices

  1. A. -2 5
  2. B. 10 5
  3. C. -2 10
  4. D. Insertion order, so 10 -2
Exact question handoffPractice Q195

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessEach time you open this Solution, one Practice Credit is used; it is not permanently unlocked. Premium Solution content also uses one credit per opening.
Continue learning

Containers and Aggregates

Review queues, dynamic and associative arrays, structures, unions, and storage ownership.

  • Data Structures
  • SystemVerilog
  • Container operations
Containers and Aggregates →
Continue practicing

Related questions

Q049 · Data StructuresDynamic-array resizingEasy→Q219 · Data StructuresQueue methodsEasyP→Q229 · Data StructuresAssociative arraysEasyP→
ASIC.FYI · Learn silicon end to end.info@asic.fyi