Quick sort is a divide and conquer algorithm that selects a random pivot element, partitions the array around it so that all elements less than the pivot are to its left and greater elements to its right, and then recursively sorts the subarrays on each side of the pivot. It has average time complexity of O(N logN) but worst case of O(N^2) when the array is already sorted or nearly sorted.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
42 views
Divide and Conquer: Quick Sort
Quick sort is a divide and conquer algorithm that selects a random pivot element, partitions the array around it so that all elements less than the pivot are to its left and greater elements to its right, and then recursively sorts the subarrays on each side of the pivot. It has average time complexity of O(N logN) but worst case of O(N^2) when the array is already sorted or nearly sorted.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
Divide And Conquer
Quick sort Idea: Select a random pivot, put it in its correct position, and sort the left and right part recursively. Time Complexity: Avg = O(N logN), Worst Case = O(N2)