Professional Documents
Culture Documents
SemiFinals Lesson3
SemiFinals Lesson3
partitions the given array around the picked pivot. There are many different
array and an element x of array as pivot, put x at its correct position in sorted
array and put all smaller elements (smaller than x) before x, and put all greater
elements (greater than x) after x. All this should be done in linear time.
Example
import java.io.*;
public class QuickSort {
// Java implementation of QuickSort
System.out.println();
}
// Driver Code
public static void main(String[] args)
{
int[] arr = { 10, 7, 8, 9, 1, 5 };
int n = arr.length;
quickSort(arr, 0, n - 1);
System.out.println("Sorted array: ");
printArray(arr, n);
}
}
Output:
ACTIVITIES
Given:
1. (45 3 51 7 90 12 52 14 10 61 9)
2. (25 35 5 17 70 15 12 14 52 )
3. (45 31 15 72 76 12 52 10 7 65)