โ† Accolite questions
CodingReported in a candidate post, May 2022

Sorting algorithms pseudo-code and complexity

Filed under Accolite

Free read 1 of 3

Bubble: O(n^2) time, O(1) space. Merge: O(n log n) time, O(n) space. Quick: O(n log n) average time, O(log n) space.

The question

Explain the time and space complexities of Bubble Sort, Merge Sort, and Quick Sort. Additionally, provide the logic or pseudo-code for Quick Sort, highlighting the partitioning step.

Approach

  1. Bubble: O(n^2) time, O(1) space. Merge: O(n log n) time, O(n) space. Quick: O(n log n) average time, O(log n) space.

Tips

  • What they are testing: Be prepared to explain the worst-case scenario for Quick Sort (O(n^2)) and how to avoid it using random pivots.
  • Common mistake: Confusing the space complexity of Merge Sort (O(n)) with Quick Sort (O(log n) for the call stack).

Related Accolite questions

Collected from public candidate posts and coding forums. Updated Nov 2026.