Friday, September 20, 2013
Saturday, September 14, 2013
Saturday, September 7, 2013
Wednesday, September 4, 2013
Quick Sort
partitionArray() partitions the array such that all the elements placed to the left of a selected pivot element are less than the pivot element and all elements to the right are more than the pivot. After every call to partitionArray, the pivot element is placed in its correct postion. The algorithm exhibits O(n^2) behavior for worst case as the partitioning function returns one subarray with n-1 elements. To fix this problem the pivot element is usually a randomly chosen element and then placed at the end of the array.
Time Complexity: O(nlogn) Best and Average Case
O(n^2) Worst case
Time Complexity: O(nlogn) Best and Average Case
O(n^2) Worst case
Subscribe to:
Posts (Atom)