Skip to content

Tag Archives: Quick Sort

Ever wondered how sort() function we use in C++/Java or sorted() in Python work internally? Here is a list of all the inbuilt sorting algorithms… Read More
Standard C library provides qsort function that can be used for sorting an array. Following is the prototype of qsort() function. // Sort an array… Read More
Prerequisite : Tail Call Elimination In QuickSort, partition function is in-place, but we need extra space for recursive function calls. A simple implementation of QuickSort… Read More
We have discussed (in tail recursion) that a recursive function is tail recursive if the recursive call is the last thing executed by the function. … Read More
In simple QuickSort algorithm, we select an element as pivot, partition the array around a pivot and recur for subarrays on the left and right… Read More
Why is Quick Sort preferred for arrays? Below are recursive and iterative implementations of Quick Sort and Merge Sort for arrays. Recursive Quick Sort for… Read More
The worst case time complexity of a typical implementation of QuickSort is O(n2). The worst case occurs when the picked pivot is always an extreme… Read More
Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping between nuts and bolts. Match… Read More
We recommend reading the following post as a prerequisite of this post. K’th Smallest/Largest Element in Unsorted Array | Set 1 Given an array and… Read More
We recommend to read following post as a prerequisite of this post.K’th Smallest/Largest Element in Unsorted Array | Set 1Given an array and a number… Read More
What is tail recursion? A recursive function is tail recursive when a recursive call is the last thing executed by the function. For example the following… Read More
Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot.… Read More
Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot.… Read More
Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot.… Read More
Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot.… Read More