Algorithmic Efficiency Flashcards

1
Q

Bubble Sort efficiency

A

O(n2)

  • -(worse case)
  • -must do n operations on n items
  • -quadratic increase

each iteration guarantees that an additional element on the right will be sorted
–this means you can not check last 1 after 1st sort, last 2 after 2nd sort, etc

make sure to stop sorting if the list is already sorted
–if no swaps are made on a pass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly