40 20 10 80 60 50 7 30 100.

Slides:



Advertisements
Similar presentations
Jyotishka Datta STAT 598Z – Sorting. Insertion Sort If the first few objects are already sorted, an unsorted object can be inserted in the sorted set.
Advertisements

Analysis of Quicksort. Quicksort Algorithm Given an array of n elements (e.g., integers): If array only contains one element, return Else –pick one element.
Quicksort Divide-and-Conquer. Quicksort Algorithm Given an array S of n elements (e.g., integers): If array only contains one element, return it. Else.
Sorting Chapter 9.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/23/2009.
S: Application of quicksort on an array of ints: partitioning.
Mergesort and Quicksort Chapter 8 Kruse and Ryba.
Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2.Solve smaller instances.
Quicksort Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer.
Chapter 9 Sorting 1. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step.
Concepts of Algorithms CSC-244 Unit 17 & 18 Divide-and-conquer Algorithms Quick Sort Shahid Iqbal Lone Computer College Qassim University K.S.A.
Partitioning in Quicksort n How do we partition the array efficiently? – choose partition element to be rightmost element – scan from right for smaller.
THỰC TIỄN KINH DOANH TRONG CỘNG ĐỒNG KINH TẾ ASEAN –
Solving Rubik's Cube By: Etai Nativ.
FW 3.4: More Circle Practice
Online Social Networks and Media
doc.: IEEE <doc#>
Progress on Beam Loading Studies
Liang Shang, Henan Normal University IHEP
The French Forest Sector Model 2.0 (FFSM++)
Economics 434: The Theory of Financial Markets
Royal Institute of Technology (KTH)
PHysics of music Lecture 2:.
Waves Test Review How do you find the amplitude of a pendulum?
Collisions Momentum: a measure of motion
Economic Growth and the Wealth of Nations
Unifying Themes in Area Formulas
Circuit modelling in Matlab/Simulink
Chapter 11 Oxidation and Reductions Charge the World
Heat, The Nature of Energy and The First Law of Thermodynamics
Certified Google Educator, Level 1
P1: A revision guide Here’s all you need to know about P1… This may help you with your exam questions  Any questions…ask your Physics teacher.
Examining the Returns to Public Investment in Science
Brawley Union High School
Student: YING, Yik Keung (EM-COSSE) Supervisors:
New trends in agro-industrialization and perspectives beyond 3ADI
Effect of urban design on the tourism facilities
Financing Supportive Housing for Veterans Bronia Clifton
Spring 2015 Events & Opportunities
Four Points By Sheraton
In 2014 the latest security monitoring product introduction
2017 Intel International Science and Engineering Fair (IISEF) Los Angeles, California, May 14–19, 2017.
The Lighthouse Keeper’s Lunch
A policy of sustainable ecological-economic development of Ukraine under the conditions of integration towards the EU PhD student - Solomiya Ohinok (Ivan.
CLE Introduction to Agile Software Acquisition
Session: New applications – new requirements:
Would you like a better grade in Physics?
Help your child bloom! Create a language-rich environment at home.
Introduction to Calculus 1: RATE OF CHANGE and FIRST PRINCIPLES
Positive Information: Mapping Its Place in the Social Sciences
Fertile Crescent. Southwest Asia 2 aka “Arabia” Saudi Arabia, Yemen, UAE, Oman, Qatar, Bahrain.
Herbal Medicine Manufacturing Week 6: Lozenges and Pastilles Gargles
Could your academics speak at festivals?
Milnrow Juniors FC.
Growing and developing the Visitor Economy in Derbyshire
B2-C1 Unit Two Lesson 2B Itineraries and adventures.
Dimitris Theodosiou , Danaos
Acknowledgements © 2013 Mark Lesmeister/Pearland ISD
Predicting the Future vs. Making the Future
The case of Nottingham (UK)
Elements of CNC machine tools: electric motors
Find the SA. Complete in your notes
Do Now a) Solve x2 – 3x – 4 = 0 by factoring: b)
BASIC PROFESSIONAL TRAINING COURSE Module I Nuclear physics and reactor theory Version 1a, September 2014 This material was prepared by the IAEA.
Figure 9.1 Time requirements as a function of the problem size n.
Quick Sort.
Quicksort Algorithm Given an array of n elements (e.g., integers):
Sorting.
Data Structures and Algorithms CS 244
Presentation transcript:

40 20 10 80 60 50 7 30 100

Pick Pivot Element Select first element in the array as pivot element 40 20 10 80 60 50 7 30 100

40 20 10 80 60 50 7 30 100 [0] [1] [2] [3] [4] [5] [6] [7] [8] s = 0 i [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i 40 20 10 80 60 50 7 30 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i 40 20 10 80 60 50 7 30 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i 40 20 10 80 60 50 7 30 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j 40 20 10 80 60 50 7 30 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j 40 20 10 80 60 50 7 30 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] 40 20 10 80 60 50 7 30 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] 40 20 10 30 60 50 7 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 60 50 7 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 60 50 7 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 60 50 7 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 60 50 7 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 60 50 7 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 60 50 7 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. Swap data[j] and data[s] 40 20 10 30 7 50 60 80 100 s = 0 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

While data[i] <= data[pivot] ++i While data[j] > data[pivot] --j If i < j swap data[i] and data[j] While j > i, go to 1. Swap data[j] and data[s] 7 20 10 30 40 50 60 80 100 s = 4 [0] [1] [2] [3] [4] [5] [6] [7] [8] i j

Partition Result 7 20 10 30 40 50 60 80 100 [0] [1] [2] [3] [4] [5] [6] [7] [8] <= data[pivot] > data[pivot]

Recursion: Quicksort Sub-arrays 7 20 10 30 40 50 60 80 100 [0] [1] [2] [3] [4] [5] [6] [7] [8] <= data[pivot] > data[pivot]