Quick Sort
Computer Science, GATE

Quick Sort

Quick Sort algorithm:

  • is one of the most efficient sorting algorithms.
  • is based on divide and conquer approach.
  • Successively divides the problem into smaller parts until the problem become so small that they can be directly solved.

In quick sort algorithm, you:

  • Select an element from the list called as pivot.
  • Partition the list into 2 parts such that:
    • All the elements towards the left end of the list are smaller than the pivot.
    • All the elements towards the right end of the list are greater than the pivot.
    Store the pivot at its correct position between the two parts of the list.

    You repeat this process for each of the two sublists created after partitioning. This process continues untill one element is left in each sublist.

Computer Science, GATE

Recursion Using C

In c, it is possible for functions to call themselves. A function calling itself is called as recursion sometimes called as ‘circular definition’. It is the process of defining something in terms of itself.