Which of the following sorting algorithms does not use recursion?
2024
Which of the following sorting algorithms does not use recursion?
- A.
Quick sort
- B.
Merge sort
- C.
Heap sort
- D.
Bottom-up merge sort
Attempted by 8 students.
Show answer & explanation
Correct answer: D
Concept: A sorting algorithm is recursion-free when its standard, defining process is an iterative pass structure -- repeatedly looping over the data -- rather than a function that calls itself on a smaller version of the same problem. Divide-and-conquer algorithms such as quick sort and the classic (top-down) merge sort are defined by recursively splitting the problem before combining results; heap sort's array-based heap operations are also conventionally coded with a recursive sift-down/heapify step in most standard treatments, even though an iterative version is possible. Bottom-up merge sort, by contrast, is defined precisely as the iterative alternative to these recursive designs -- it has no recursive step at all.
Application: Bottom-up merge sort sorts an array of n elements purely iteratively, without any recursive call:
Treat every single element as a sorted subarray of size 1.
Pass 1: merge adjacent subarrays of size 1 into sorted subarrays of size 2, scanning left to right.
Pass 2: merge adjacent subarrays of size 2 into sorted subarrays of size 4.
Continue doubling the subarray size on each pass (8, 16, and so on) until one pass produces a single sorted subarray covering the whole array.
Each pass is a simple loop over the array — there is no function calling itself on a smaller instance of the same array, so bottom-up merge sort is the algorithm that does not use recursion.
Contrast: The other three options are all normally implemented with recursion:
Quick sort partitions the array around a pivot, then calls itself on the left and right partitions.
The standard (top-down) merge sort recursively splits the array in half until single elements remain, then merges on the way back up the call stack.
Heap sort's core heapify step is conventionally written as a function that calls itself to sift a node down the heap in most standard treatments (an iterative version is possible, but that is a secondary implementation choice, not what characterizes the algorithm).
Cross-check: The top-down algorithms all need a call stack whose depth grows with the number of splits (about log n), while bottom-up merge sort's loop-based passes need no call stack at all — confirming bottom-up merge sort as the non-recursive method among the four.