Enter an array separated by commas as : 16,15,15,10,1 or just press the hand icon to generate a random array then press enter or Sort button. Sorting will start and you can watch each pass as it gets sorted. When it shows green it means the two of them are being compared when red shows, it means the left number is greater than right number so it needs swapping The blue color means the number is at its correct position and thus sorted it will continue to check other numbers until it reaches end.
Quick sort was developed by Tony Hoare in 1960. It is a divide-and-conquer algorithm that is efficient for large datasets. Quick sort has become one of the most widely used sorting algorithms due to its performance in practice and its ability to sort in place.
O(n log n) - When the pivot divides the array into
nearly equal halves.O(n log n) - The average case performance is
efficient.O(n2) - Occurs when the smallest or largest
element
is always chosen as the pivot.Space Complexity: O(log n) - Due to the recursive stack space used
during the algorithm's execution.
function quickSort(arr, low, high):
if low < high:
pi = partition(arr, low, high)
quickSort(arr, low, pi - 1)
quickSort(arr, pi + 1, high)
function partition(arr, low, high):
pivot = arr[high]
i = low - 1
for j from low to high - 1:
if arr[j] <= pivot:
i = i + 1
swap arr[i] and arr[j]
swap arr[i + 1] and arr[high]
return i + 1
Quick sort is a highly efficient sorting algorithm that utilizes the divide-and-conquer strategy.
Despite its worst-case time complexity of O(n2), it is widely used due to
its
average-case efficiency and practical performance.
Quick sort is a divide-and-conquer algorithm built around the idea of a pivot. Its efficiency comes from partitioning the array in place:
On average quick sort makes O(n log n) comparisons and is famously cache-friendly,
which is why it is so fast in practice - but its worst case is O(n²) when the pivot is
consistently the smallest or largest element (randomizing the pivot avoids this).