Partitioning%20in%20Quicksort - PowerPoint PPT Presentation

About This Presentation
Title:

Partitioning%20in%20Quicksort

Description:

Scan from left for larger element. Scan from right for smaller element. Exchange. ... – PowerPoint PPT presentation

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

less

Transcript and Presenter's Notes

Title: Partitioning%20in%20Quicksort


1
Partitioning in Quicksort
  • How do we partition in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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 in-place efficiently?
  • Partition element 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