Sorting & searching vocabulary

  • Bubble sort O(N²) — educational only; use built-in sort() in production
  • Merge sort / Timsort O(N log N) — stable, predictable; built into Python/Java sorted()
  • Binary search O(log N) — requires sorted input; returns index or -1
  • Linear search O(N) — works on unsorted arrays; checks each element in order
  • "Iterates through one by one" → linear; "discards half each step" → binary

Question 0 of 5

A code review comment says: "This uses bubble sort — swap adjacent elements repeatedly until sorted." When would this be an acceptable choice?