Best and worst case work for 50 values

An early-exit bubble sort sorts lists of 50 distinct values into ascending order. Each pass compares adjacent pairs from left to right across the unsorted part, which shrinks by one position after every pass, and the algorithm stops after the first pass that makes no swaps or when no unsorted pairs remain. Give, as whole numbers, the number of comparisons when the list is already in ascending order, the number of comparisons when the list is in descending order, and the number of swaps when the list is in descending order.

Your answers

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: