Quick sort data structures

chauhankapil 380 views 8 slides May 21, 2020
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

Quick sort method and Example


Slide Content

Quick Sort in Data Structures
Prof. Neeraj Bhargava
Kapil Chauhan
Department of Computer Science
School of Engineering & Systems Sciences
MDS University, Ajmer

Introduction
Quick sort is a fast sorting algorithm used to sort a list
of elements.
The quick sort algorithm attempts to separate the list
of elements into two parts and then sort each part
recursively.

Cont..
That means it usedivide and conquerstrategy.
In quick sort, the partition of the list is performed
based on the element calledpivot.

Cont…
Here pivot element is one of the elements in the list.
The list is divided into two partitions such that"all
elements to the left of pivot are smaller than the
pivot and all elements to the right of pivot are
greater than or equal to the pivot".

Cont..
It is also calledpartition-exchange sort. This
algorithm divides the list into three main parts:
Elements less than thePivotelement
Pivot element(Central element)
Elements greater than the pivot element

Example

Algorithm
Step 1− Choose the highest index value has pivot
Step 2− Take two variables to point left and right of the list
excluding pivot
Step 3− left points to the low index
Step 4− right points to the high
Step 5− while value at left is less than pivot move right
Step 6− while value at right is greater than pivot move left
Step 7− if both step 5 and step 6 does not match swap left
and right
Step 8− if left ≥ right, the point where they met is new
pivot

Assignment
Explain Quick Sort in data structure with suitable
example and discuss basic operation.
Tags