Which of the following algorithm design techniques is used in the quicksort…
2018
Which of the following algorithm design techniques is used in the quicksort algorithm?
- A.
Dynamic programming
- B.
Backtracking
- C.
Divide and conquer
- D.
Greedy method
Attempted by 236 students.
Show answer & explanation
Correct answer: C
The Divide and Conquer strategy works by breaking a problem down into smaller sub-problems, solving them recursively, and then combining the results. Quicksort follows these three steps:
Divide (Partitioning): The algorithm selects an element called a pivot. It then rearranges the array so that all elements smaller than the pivot are on the left, and all elements larger than the pivot are on the right.
Conquer: It recursively applies the same logic to the left and right sub-arrays.
Combine: Unlike Merge Sort, Quicksort does not require a formal "combine" step because the partitioning happens in-place. Once the sub-arrays are sorted, the entire array is sorted.