1. Which of the following options is an instance of divide and conquer
a. merge sort
b. Bubble sort
c. selection sort
d. insertion sort
Answer:
A. Quick Sort and B. Merge Sort
Explanation:
Quick sort uses a divide-and-conquer strategy. It works by selecting a 'pivot' element from the sorting-array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot-value. The sub-arrays are then sorted recursively.
Merge sort follows steps in divide-and conquer fashion:
- Divide the unsorted array into n sub-arrays, each containing one element (array of one element is considered sorted).
- Repeatedly merge sub-arrays to produce new sorted sub-arrays until there is only one sub-array remaining. This will be the sorted array.
Comments
Leave a comment