Write a Java Program to perform Quick Sort using Static Function

By | February 27, 2017

Java Program to perform Quick Sort

Quicksort is a divide and conquer algorithm. In a divide and conquer sorting algorithm the original data is separated into two parts “divide” which are individually sorted and “conquered” and then combined.

If the array contains only one element or zero elements than the array is sorted.

If the array contains more than one element than:

  • Select an element from the array. This element is called the “pivot element”. For example select the element in the middle of the array.
  • All elements which are smaller then the pivot element are placed in one array and all elements which are larger are placed in another array.
  • Sort both arrays by recursively applying Quicksort to them.
  • Combine the arrays.

Quicksort can be implemented to sort “in-place”. This means that the sorting takes place in the array and that no additional array needs to be created.

This is a Java Program to perform Quick Sort Algorithm.Here is the source code of the Java program to implement Quick Sort Algorithm. The program output is also shown below.







Leave a Reply