Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Associative-array traversal

Hardware interview practice

Associative-array traversal

EasyData StructuresSystemVerilog

What key values are displayed?

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 →
Starting point

Question code

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
Continue practicing

Related questions

Data StructuresQueue methods→Data StructuresDynamic-array resizing→
asic.fyi · Learn silicon end to end.info@asic.fyi