Tracing two passes

Bubble sort sorts the list 8, 3, 5, 1, 9, 2 into ascending order. Each pass compares adjacent pairs from left to right across the unsorted part and swaps a pair when the left value is larger. Fill in the value at each position after pass 1 and after pass 2, and the number of swaps made during each of those passes.

StatePos 1Pos 2Pos 3Pos 4Pos 5Pos 6Swaps in pass
Start835192none
After pass 1
After pass 2

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Bubble Sort Questions: