Partitioning in Quicksort - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Partitioning in Quicksort

Description:

unpartitioned. 2. Partitioning in Quicksort. How do we partition the array efficiently? ... unpartitioned. partition is complete. C. I. I. C. K. L. O. R. T. U ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 20
Provided by: kevin597
Category:

less

Transcript and Presenter's Notes

Title: Partitioning in Quicksort


1
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

2
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

Q
U
I
C
K
S
O
R
T
I
S
C
O
O
L
3
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

Q
U
I
C
K
S
O
R
T
I
S
C
O
O
L
4
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

Q
U
I
C
K
S
O
R
T
I
S
C
O
O
L
5
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

Q
U
I
C
K
S
O
R
T
I
S
C
O
O
L
6
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
U
I
C
K
S
O
R
T
I
S
Q
O
O
L
7
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
U
I
C
K
S
O
R
T
I
S
Q
O
O
L
8
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
U
I
C
K
S
O
R
T
I
S
Q
O
O
L
9
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
U
I
C
K
S
O
R
T
I
S
Q
O
O
L
10
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
I
I
C
K
S
O
R
T
U
S
Q
O
O
L
11
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
I
I
C
K
S
O
R
T
U
S
Q
O
O
L
12
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
I
I
C
K
S
O
R
T
U
S
Q
O
O
L
13
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
I
I
C
K
S
O
R
T
U
S
Q
O
O
L
14
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
I
I
C
K
S
O
R
T
U
S
Q
O
O
L
15
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
I
I
C
K
S
O
R
T
U
S
Q
O
O
L
16
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
I
I
C
K
S
O
R
T
U
S
Q
O
O
L
17
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

C
I
I
C
K
S
O
R
T
U
S
Q
O
O
L
18
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

swap with partitioning element
pointers cross
C
I
I
C
K
S
O
R
T
U
S
Q
O
O
L
19
Partitioning in Quicksort
  • How do we partition the array efficiently?
  • choose partition element to be rightmost element
  • scan from left for larger element
  • scan from right for smaller element
  • exchange
  • repeat until pointers cross

partition is complete
C
I
I
C
K
L
O
R
T
U
S
Q
O
O
S
Write a Comment
User Comments (0)
About PowerShow.com