0% found this document useful (0 votes)
115 views

Quick Sort: - . - DR V K Pathak

The document presents on the quick sort algorithm. Quick sort is a divide and conquer algorithm that works by selecting a pivot element and partitioning the array into two subarrays - one with elements less than the pivot and one with elements greater than the pivot. It then recursively sorts the two subarrays. The document discusses the quick sort algorithm, provides pseudocode, and walks through an example of partitioning an array.

Uploaded by

api-19981779
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views

Quick Sort: - . - DR V K Pathak

The document presents on the quick sort algorithm. Quick sort is a divide and conquer algorithm that works by selecting a pivot element and partitioning the array into two subarrays - one with elements less than the pivot and one with elements greater than the pivot. It then recursively sorts the two subarrays. The document discusses the quick sort algorithm, provides pseudocode, and walks through an example of partitioning an array.

Uploaded by

api-19981779
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 67

PRESENTATION

on
QUICK SORT
Submitted to :
Dr. V. K. Pathak

Submitted by:
Abhishek Kumar Shukla
88/07
III rd B.Tech
070451
Topics to be
covered
• Quick sort as Devide & conquer
method
• Algorithm of quick sort
• Analysis of complexity of quick sort
• Programs of quick sort
• Outputs of sorting algorithm

Quick Sort :
Introduction
• One of the fastest in-memory sorting algorithms
• Proposed by Tony Hoarein 1962.
• The algorithm is a demonstration of the divide-
and conquer strategy.
• It first divides the array into two subarrays (of
arbitrary sizes) in such a way that every element
of the first part is smaller than or equal to every
element of the second part - partition.
• The two subarrayscan be sorted individually,
within their own areas. The final array is sorted -
without any merging process.
• The average-time complexity of Quicksort is O(n
D iv id e - a n d -
C o n
Divide and Conquer
design.
q
is au e
methodrof algorithm


This method has three distinct steps:
–Divide: If the input size is too large to
deal with in a straightforward manner,
divide the data into two or more disjoint
subsets.
–Recur: Use divide and conquer to solve the
subproblems associated with the data
subsets.
–Conquer: Take the solutions to the
subproblems and “merge” these solutions
into a solution for the original problem.
Quick - Sort
1) Divide : If the sequence S has 2 or
more elements, select an element x from S
to be your pivot. Any arbitrary element,
like the first, will do. Remove all the
elements of S and divide them into 3
sequences:
L, holds S’s elements less than x
E, holds S’s elements equal to x
G, holds S’s elements greater than x
2) Recurse: Recursively sort L and G
3) Conquer: Finally, to put elements back
into S in order, first inserts the
elements of L, then those of E, and those
of G.
Quicksort Algorithm
Given an array of n elements (e.g.,
integers):
If array only contains one element, return
Else
–pick one element to use as pivot.
–Partition elements into two sub-arrays:
Elements less than or equal to pivot
Elements greater than pivot
–Quicksort two sub-arrays
–Return results
Example
We are given array of n integers to
sort:
40 20 10 80 60 50 7 30 100
Pick Pivot Element
There are a number of ways to pick
the pivot element. In this example,
we will use the first element in
the array:
10
40 20 10 80 60 50 7 30 0
Partitioning Array
 Given a pivot, partition the elements of
the array such that the resulting array
consists of:
1.One sub-array that contains elements
>= pivot
2.Another sub-array that contains elements
< pivot
3.
 The sub-arrays are stored in the original
data array.

 Partitioning loops through, swapping


elements below/above pivot.
pivot_index = 0 10
40 20 10 80 60 50 7 30
0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index

pivot_index = 0 10
40 20 10 80 60 50 7 30 0
[0] [1] [2] [3] [4]
[5] [6] [7] [8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index

pivot_index = 0 10
40 20 10 80 60 50 7 30 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index

pivot_index = 0 10
40 20 10 80 60 50 7 30 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index

1.

pivot_index = 0 10
40 20 10 80 60 50 7 30 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index

1.

pivot_index = 0 10
40 20 10 80 60 50 7 30 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]

1.

pivot_index = 0 10
40 20 10 80 60 50 7 30 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]

1.

pivot_index = 0 10
40 20 10 30 60 50 7 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 60 50 7 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 60 50 7 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 60 50 7 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 60 50 7 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 60 50 7 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 60 50 7 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.

1.

pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.
pivot_index = 0 10
40 20 10 30 7 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.
10
pivot_index = 4 7 20 10 30 40 50 60 80 0
[0] [1] [ 2] [ 3] [4] [5] [6] [ 7] [ 8]

too_big_index too_small_index
Partition Result

10
7 20 10 30 40 50 60 80
0
[0] [1] [2] [3] [4] [5] [6] [7] [8]

<= data[pivot] > data[pivot]


Recursion: Quicksort
Sub-arrays

10
7 20 10 30 40 50 60 80
0
[0] [1] [2] [3] [4] [5] [6] [7] [8]

<= data[pivot] > data[pivot]


Quicksort Analysis
• Assume that keys are random,
uniformly distributed.
• What is best case running time?
– Recursion:
1.Partition splits array in two sub-arrays
of size n/2
2.Quicksort each sub-array
– Depth of recursion tree? O(log2n)
– Number of accesses in partition? O(n)
B e st C a se

If w e a re lu cky , Pa rtitio n sp lits th e


a rra y e veTn(lny) = 2T (n / 2) + Θ(n)
Quicksort Analysis
• Assume that keys are random,
uniformly distributed.
• Best case running time: O(n log2n)
• Worst case running time?

Quicksort: Worst Case
• Assume first element is chosen as
pivot.
• Assume we get array that is already
in order:
pivot_index = 0 10
2 4 10 12 13 50 57 63

0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
1 .While data[too_big_index] <= data[pivot]
++too_big_index
1 .While data[too_small_index] > data[pivot]
--too_small_index
1 .If too_big_index < too_small_index
swap data[too_big_index] and data[too_small_index]
1 .While too_small_index > too_big_index, go to 1.
2 .Swap data[too_small_index] and data[pivot_index]

1.

pivot_index = 0 2 4 10 12 13 50 57 63 10
0
[0] [1] [2] [3] [4] [5] [6] [7]

too_big_index too_small_index
Worst case
l Worst case?
l Each call to Partition splits the array into an empty
array and n-1 array
l
l
l
l
l
l
l
l
l
l
Quicksort Analysis
• Assume that keys are random, uniformly
distributed.
• Best case running time: O(n log2n)
• Worst case running time?
– Recursion:
1.Partition splits array in two sub-arrays:
• one sub-array of size 0
• the other sub-array of size n-1
2.Quicksort each sub-array
– Depth of recursion tree? O(n)
– Number of accesses per partition? O(n)


Quicksort Analysis
• Assume that keys are random, uniformly
distributed.
• Best case running time: O(n log2n)
• Worst case running time: O(n2)!!!


W o rst C a se

What is the worst case?


One side of the parition has only one
element
T (n) = T (1) + T (n − 1) + Θ(n)
= T (n − 1) + Θ(n)
n
= ∑ Θ( k )
k =1
n
= Θ(∑ k )
k =1

= Θ( n 2 )
Worst Case
Worse case running time

T (n) = T (n − 1) + Θ(n)

Which is? Θ(n 2 )

When does this happen?


sorted
reverse sorted
near sorted/reverse sorted
Improved Pivot Selection
Pick median value of three elements from
data array:
 data[0], data[n/2], and data[n-1].

Use this median value as pivot.



P ro g ra m o f q u ick so rt
# include < stdio. h >
# include < stdlibh. >
# include < conio . h >
# include < time . h >
# define MAX 10000

vo id q u ick_so rt( in t [ ] , in t, in t);


in t p a rtitio n ( in t [ ] , in t, in t);

vo id m a in ()
{
in t n , ia
, [M A X ];
clo ck_t sta rt, e n d ;
clrscr();
ra n d o m ize ();

p rin tf(" \n E n te r n o . o f e le m e n ts :" );


sca n f(" % d " ,&n );
fo r( i= 0 ; i< n ; i+ + )
a [ i] = ra n d o m ( 1 0 0 0 0 );
p rin tf(" \n U n so rte d d a ta -> \n " );
fo r( i= 0 ; i< n ; i+ + )
p rin tf(" % d \t" , a [ i] );

p rin tf(" \n Pre ss a n y ke y to sta rt so rtin g ..." );


g e tch ();
sta rt= clo ck ();
q u ick_so rt( a , 0 , n -1 );

p rin tf(" \n \n S o rte d d a ta -> \n " );


fo r( i= 0 ; i< n ; i+ + )
p rin tf(" % d \t" , a [ i] );
e n d = clo ck ();
p rin tf(" \n T h e tim e e la p se d ( in se c ): % f\n " , ( e n d -
sta rt)/ C LK _TC K );

g e tch ();
}
vo id q u ick_so rt( in t a [ ] , in t
li
, nt u)
{
in t j;
if( l< u )
{
j= p a rtitio n ( a , lu
, );
q u ick_so rt( a , lj , -1 );
q u ick_so rt( a , j+ 1 , u );
}
}

in t p a rtitio n ( in t a [ ] , in t li
, nt
u)
{
in t v , i, j, te m p ;
v = a [ l] ; i= l; j= u + 1 ;
do
{
do
i+ + ;
w h ile ( a [ i] < v &&i< = u );

do
j--;
w h ile ( a [ j] > v );

if( i< j)
{
te m p = a [ i] ;
a [ i] = a [ j] ;
a [ j] = te m p ;
}
} while ( i< j);

a [ l] = a [ j] ;
a [ j] = v ;
re tu rn ( j);
}
Outputs
E n te r n o . o f e le m e n ts : 1 0

U n so rte d d a ta ->
852 7203 8009 3791 9857 9386
3427 3275 3368 4027

Pre ss a n y ke y to sta rt so rtin g ...

S o rte d d a ta ->
852 3275 3368 3427 3791 4027
7203 8009 9386 9857

T h e tim e e la p se d ( in se c ): 0 . 0 0 0 0 0 0
Enter no. of elements :50

Unsorted data ->


1843 359 2429 9844 5198 5325 5978 8434
8110 3569
4169 2083 9749 9028 3403 973 9662 3472
7257 1133
3403 7949 8645 7144 6462 4169 8872 254
4936 3021
4529 1587 6366 2402 8140 5145 9201 1552
3539 269
4301 4080 1871 8278 6933 6871 9187 2939
2695 7053

Press any key to start sorting...

Sorted data ->


254 269 359 973 1133 1552 1587 1843
1871 2083
2402 2429 2695 2939 3021 3403 3403 3472
3539 3569
4080 4169 4169 4301 4529 4936 5145 5198
5325 5978
Outputs of Quick Sort
algorithm
No.of 100 1000 5000 7000 10000
elements

Time in 0.000000 0.000000 0.054945 0.109890 0.109890


seconds
Thank
you !

You might also like