Add the text "The time complexity of this algorithm is O(nLogn), be it best case, average case or worst case. It's time complexity can be easily understood from the recurrence eqaution :T(n) = 2T(n/2) + n." to the article (#22663)
This commit is contained in:
@ -21,7 +21,7 @@ Following are some standard algorithms that are Divide and Conquer algorithms.
|
||||
|
||||
2) Quicksort is a sorting algorithm. The algorithm picks a pivot element, rearranges the array elements in such a way that all elements smaller than the picked pivot element move to left side of pivot, and all greater elements move to right side. Finally, the algorithm recursively sorts the subarrays on left and right of pivot element.
|
||||
|
||||
3) Merge Sort is also a sorting algorithm. The algorithm divides the array in two halves, recursively sorts them and finally merges the two sorted halves.
|
||||
3) Merge Sort is also a sorting algorithm. The algorithm divides the array in two halves, recursively sorts them and finally merges the two sorted halves. The time complexity of this algorithm is O(nLogn), be it best case, average case or worst case. It's time complexity can be easily understood from the recurrence eqaution :T(n) = 2T(n/2) + n.
|
||||
|
||||
4) Closest Pair of Points The problem is to find the closest pair of points in a set of points in x-y plane. The problem can be solved in O(n^2) time by calculating distances of every pair of points and comparing the distances to find the minimum. The Divide and Conquer algorithm solves the problem in O(nLogn) time.
|
||||
|
||||
|
Reference in New Issue
Block a user