Docsity

Data Structures and Algorithms: CSCE 350 Announcement and Quicksort Explanation - Prof. C., Study notes of Computer Science

Toggle sidebar
bg1
1
CSCE 350:
Data Structures and Algorithms
Chin-Tser Huang
University of South Carolina
02/18/2009 2
Announcement
๎š„Reading assignment: Chapter 4.2, 4.3
๎š„Homework 3 is assigned on February 16
and is due on Wednesday, February 25
in class
๎š„Please download it from class website
๎š„Have your answers neatly typed
๎š„Explain your answer clearly and adequately
by showing the steps
02/18/2009 3
Quicksort
๎š„Select a
pivot
(partitioning element)
๎š„Rearrange the list so that all the elements in the positions
before the pivot are smaller than or equal to the pivot and
those after the pivot are larger than or equal to the pivot
๎š„Exchange the pivot with the last element in the first (i.e., โ‰ค
sublist) โ€“ the pivot is now in its final position
๎š„Sort the two sublists
p
A[i] โ‰คpA[i]p
โ‰ฅ
02/18/2009 4
Pseudocode of Quicksort

Partial preview of the text

Download Data Structures and Algorithms: CSCE 350 Announcement and Quicksort Explanation - Prof. C. and more Study notes Computer Science in PDF only on Docsity!

CSCE 350:

Data Structures and Algorithms

Chin-Tser Huang

[email protected]

University of South Carolina

02/18/2009 2

Announcement

ย„ Reading assignment: Chapter 4.2, 4.

ย„ Homework 3 is assigned on February 16

and is due on Wednesday, February 25

in class

ย„ Please download it from class website

ย„ Have your answers neatly typed

ย„ Explain your answer clearly and adequately

by showing the steps

02/18/2009 3

Quicksort

ย„ Select apivot (partitioning element) ย„ Rearrange the list so that all the elements in the positions before the pivot are smaller than or equal to the pivot and those after the pivot are larger than or equal to the pivot ย„ Exchange the pivot with the last element in the first (i.e., โ‰ค sublist) โ€“ the pivot is now in its final position

ย„ Sort the two sublists

p

A[ i ] โ‰ค p A[ i ] โ‰ฅ p

02/18/2009 4

Pseudocode of Quicksort