Physics I / Searching and sorting ideas
Practice question · Sort into groups

Classify each sort as O(n2n^{2}) average or O(n log n) average.

Groups: O(n2n^{2}) · O(n log n)

Hints
  1. Ask whether the algorithm splits the problem in half or scans repeatedly.
  2. Divide-and-conquer buys the logarithmic factor.
Show the answer

O(n2n^{2}): Bubble sort, Insertion sort, Selection sort

O(n log n): Merge sort, Quick sort (avg)

Why

Divide-and-conquer sorts achieve O(n log n); simple nested-loop sorts are O(n2n^{2}).

Read the lesson: Searching and sorting ideas →

Practise Searching and sorting ideas

The app has 8 more questions on this lesson, and keeps your place in the course. Physics I is free to start.

More questions on Searching and sorting ideas