(a) Explain how the divide-and-conquer algorithmic technique works in general? (b) Specify the steps of the divide-and-conquer algorithm for the quick sort algorithm (First present the quick sort algorithm and then explain the steps accordingly). In which situation we are able to have O(nlogn) as the running time of this algorithm? Why?

Respuesta :

Answer: A-A divide and conquer algorithm works by recursively dividing a problem into two or more sub-problems of the same or related type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem.

Explanation:

B-Quicksort is a divide-and-conquer sorting algorithm in which division is dynamically carried out.

The steps are  

Divide: Rearrange the elements and split the array into two subarrays and an element in between such that so that each element in the left subarray is less than or equal the middle element and each element in the right subarray is greater than the middle element.

Conquer: Recursively sort the two subarrays.  

Combine: None.

C- We are able to have O(nlogn) as the running time of this algorithm when the array is split half and half. Then each element belongs to a region in which partition is carried out at most dlog ne times, so it’s O(n log n).This is because it is one of the best cases.