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

Hardware interview practice

Bubble sort in place

EasyArraysSystemVerilog

Sort a dynamic array of integers in ascending order using bubble 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]

Adjacent out-of-order pairs are exchanged until a pass performs no swaps.

What to cover

Requirements

  1. Modify the input array in place.
  2. Stop early when a full pass performs no swaps.
  3. Handle empty and one-element arrays.
Continue practicing

Related questions

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