Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ167
Page ↗
Q167FWASIC interview problem

Insertion sort in place

TechniquesSortingDynamic arrayStable
DifficultyEasy
TopicArrays
LanguageSystemVerilog
Requirements3 checkpoints
01

Problem

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

Example input and output

Use this case to check your interpretation
Input
values = [5, 1, 4, 2]
Output
[1, 2, 4, 5]
Explanation

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

02

Requirements (3)

  • Modify the input array in place.
  • Keep equal values in their original relative order.
  • Handle negative values and duplicate values.