Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Insertion sort in place

Hardware interview practice

Insertion sort in place

EasyArraysSystemVerilog

Sort a dynamic array of integers in ascending order using insertion sort.

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
values = [5, 1, 4, 2]
Expected output
[1, 2, 4, 5]

Each element is inserted into the already sorted prefix while equal elements retain their order.

What to cover

Requirements

  1. Modify the input array in place.
  2. Keep equal values in their original relative order.
  3. Handle negative values and duplicate values.
Continue practicing

Related questions

ArraysBubble sort in place→ArraysSort only a subrange→
asic.fyi · Learn silicon end to end.info@asic.fyi