Programming Examples

Algorithm for Quick Sort


QuickSort(low,high)

1. If (low > high):

Return.

2. Set pivot = arr[low].

3. Set i = low + 1.

4. Set j = high.

5. Repeat step 6 until i > high or arr[i]> pivot.

// Search for an element greater than the pivot.             

6. Increment i by 1.

7. Repeat step 8 until j < low or arr[j] < pivot.   //Search for an element smaller than pivot

8. Decrement j by 1.

9. If i < j: 

            // If greater element is on the left of   //smaller element

Swap arr[i] with arr[j].

     10. If i <= j:

  Go to step 5. // Continue the search

     11.   If low < j:

  Swap arr[low] with arr[j].     //Swap pivot with last element in first part of     //the list

Output

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz