SlideShare a Scribd company logo
1 of 29
Download to read offline
CS 332: Algorithms Linear-Time Sorting Continued Medians and Order Statistics
Review: Comparison Sorts ,[object Object],[object Object],[object Object],[object Object],[object Object]
Review: Counting Sort  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Review: Counting Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Review: Radix Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Review: Radix Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Radix Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Radix Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Radix Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Radix Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary: Radix Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Bucket Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Order Statistics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Order Statistics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Finding Order Statistics:  The Selection Problem ,[object Object],[object Object],[object Object],[object Object]
Randomized Selection ,[object Object],[object Object],[object Object],[object Object],[object Object],   A[q]    A[q] q p r
Randomized Selection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],   A[q]    A[q] k q p r
Randomized Selection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Randomized Selection ,[object Object],[object Object],[object Object],What happened here?
Randomized Selection ,[object Object],What happened here? “ Split” the recurrence What happened here? What happened here? What happened here? The recurrence we started with Substitute T(n)    cn  for T(k)  Expand arithmetic series Multiply it out
Randomized Selection ,[object Object],What happened here? Subtract c/2 What happened here? What happened here? What happened here? The recurrence so far Multiply it out   Rearrange the arithmetic What we set out to prove
Worst-Case Linear-Time Selection ,[object Object],[object Object],[object Object],[object Object],[object Object]
Worst-Case Linear-Time Selection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Worst-Case Linear-Time Selection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Worst-Case Linear-Time Selection ,[object Object],[object Object],??? ??? ??? ??? ???  n/5       n/5 Substitute T(n) = cn Combine fractions  Express in desired form What we set out to prove
Worst-Case Linear-Time Selection ,[object Object],[object Object],[object Object],[object Object]
Linear-Time Median Selection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Linear-Time Median Selection ,[object Object],[object Object],[object Object],[object Object]
The End

More Related Content

What's hot (20)

3.8 quicksort
3.8 quicksort3.8 quicksort
3.8 quicksort
 
Linear sorting
Linear sortingLinear sorting
Linear sorting
 
Lec5
Lec5Lec5
Lec5
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
median and order statistics
median and order statisticsmedian and order statistics
median and order statistics
 
Quick sort algorithn
Quick sort algorithnQuick sort algorithn
Quick sort algorithn
 
5.5 back tracking 02
5.5 back tracking 025.5 back tracking 02
5.5 back tracking 02
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesLecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrences
 
Lec23
Lec23Lec23
Lec23
 
Algorithm big o
Algorithm big oAlgorithm big o
Algorithm big o
 
5.4 randomized datastructures
5.4 randomized datastructures5.4 randomized datastructures
5.4 randomized datastructures
 
algorithm unit 1
algorithm unit 1algorithm unit 1
algorithm unit 1
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
220exercises2
220exercises2220exercises2
220exercises2
 
Lecture 4 asymptotic notations
Lecture 4   asymptotic notationsLecture 4   asymptotic notations
Lecture 4 asymptotic notations
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
algorithm Unit 4
algorithm Unit 4 algorithm Unit 4
algorithm Unit 4
 
Scalable k-means plus plus
Scalable k-means plus plusScalable k-means plus plus
Scalable k-means plus plus
 
Big oh Representation Used in Time complexities
Big oh Representation Used in Time complexitiesBig oh Representation Used in Time complexities
Big oh Representation Used in Time complexities
 
Big o
Big oBig o
Big o
 

Viewers also liked

Skiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingSkiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingzukun
 
lecture 25
lecture 25lecture 25
lecture 25sajinsc
 
lecture 11
lecture 11lecture 11
lecture 11sajinsc
 
Next higher number with same number of binary bits set
Next higher number with same number of binary bits setNext higher number with same number of binary bits set
Next higher number with same number of binary bits setGowriKumar Chandramouli
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting AlgorithmsShivam Singh
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithmsmultimedia9
 

Viewers also liked (8)

Algorithm
AlgorithmAlgorithm
Algorithm
 
Skiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingSkiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sorting
 
lecture 25
lecture 25lecture 25
lecture 25
 
lecture 11
lecture 11lecture 11
lecture 11
 
Next higher number with same number of binary bits set
Next higher number with same number of binary bits setNext higher number with same number of binary bits set
Next higher number with same number of binary bits set
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 

Similar to lecture 10

Counting Sort Lowerbound
Counting Sort LowerboundCounting Sort Lowerbound
Counting Sort Lowerbounddespicable me
 
lecture 9
lecture 9lecture 9
lecture 9sajinsc
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Hossain Md Shakhawat
 
Fundamental computing algorithms
Fundamental computing algorithmsFundamental computing algorithms
Fundamental computing algorithmsGanesh Solanke
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptxSajalFayyaz
 
Skiena algorithm 2007 lecture08 quicksort
Skiena algorithm 2007 lecture08 quicksortSkiena algorithm 2007 lecture08 quicksort
Skiena algorithm 2007 lecture08 quicksortzukun
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sortingsajinis3
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0BG Java EE Course
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqPradeep Bisht
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................nourhandardeer3
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquerchidabdu
 

Similar to lecture 10 (20)

Counting Sort Lowerbound
Counting Sort LowerboundCounting Sort Lowerbound
Counting Sort Lowerbound
 
lecture 9
lecture 9lecture 9
lecture 9
 
Sorting2
Sorting2Sorting2
Sorting2
 
Cis435 week06
Cis435 week06Cis435 week06
Cis435 week06
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)
 
Daa chapter5
Daa chapter5Daa chapter5
Daa chapter5
 
Fundamental computing algorithms
Fundamental computing algorithmsFundamental computing algorithms
Fundamental computing algorithms
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptx
 
Chapter 4 ds
Chapter 4 dsChapter 4 ds
Chapter 4 ds
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
 
algorithm Unit 2
algorithm Unit 2 algorithm Unit 2
algorithm Unit 2
 
Skiena algorithm 2007 lecture08 quicksort
Skiena algorithm 2007 lecture08 quicksortSkiena algorithm 2007 lecture08 quicksort
Skiena algorithm 2007 lecture08 quicksort
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquer
 
Sorting
SortingSorting
Sorting
 
Slide2
Slide2Slide2
Slide2
 

More from sajinsc

lecture 30
lecture 30lecture 30
lecture 30sajinsc
 
lecture 29
lecture 29lecture 29
lecture 29sajinsc
 
lecture 28
lecture 28lecture 28
lecture 28sajinsc
 
lecture 27
lecture 27lecture 27
lecture 27sajinsc
 
lecture 26
lecture 26lecture 26
lecture 26sajinsc
 
lecture 24
lecture 24lecture 24
lecture 24sajinsc
 
lecture 23
lecture 23lecture 23
lecture 23sajinsc
 
lecture 22
lecture 22lecture 22
lecture 22sajinsc
 
lecture 21
lecture 21lecture 21
lecture 21sajinsc
 
lecture 20
lecture 20lecture 20
lecture 20sajinsc
 
lecture 19
lecture 19lecture 19
lecture 19sajinsc
 
lecture 18
lecture 18lecture 18
lecture 18sajinsc
 
lecture 17
lecture 17lecture 17
lecture 17sajinsc
 
lecture 16
lecture 16lecture 16
lecture 16sajinsc
 
lecture 15
lecture 15lecture 15
lecture 15sajinsc
 
lecture 14
lecture 14lecture 14
lecture 14sajinsc
 
lecture 13
lecture 13lecture 13
lecture 13sajinsc
 
lecture 12
lecture 12lecture 12
lecture 12sajinsc
 
lecture 8
lecture 8lecture 8
lecture 8sajinsc
 
lecture 7
lecture 7lecture 7
lecture 7sajinsc
 

More from sajinsc (20)

lecture 30
lecture 30lecture 30
lecture 30
 
lecture 29
lecture 29lecture 29
lecture 29
 
lecture 28
lecture 28lecture 28
lecture 28
 
lecture 27
lecture 27lecture 27
lecture 27
 
lecture 26
lecture 26lecture 26
lecture 26
 
lecture 24
lecture 24lecture 24
lecture 24
 
lecture 23
lecture 23lecture 23
lecture 23
 
lecture 22
lecture 22lecture 22
lecture 22
 
lecture 21
lecture 21lecture 21
lecture 21
 
lecture 20
lecture 20lecture 20
lecture 20
 
lecture 19
lecture 19lecture 19
lecture 19
 
lecture 18
lecture 18lecture 18
lecture 18
 
lecture 17
lecture 17lecture 17
lecture 17
 
lecture 16
lecture 16lecture 16
lecture 16
 
lecture 15
lecture 15lecture 15
lecture 15
 
lecture 14
lecture 14lecture 14
lecture 14
 
lecture 13
lecture 13lecture 13
lecture 13
 
lecture 12
lecture 12lecture 12
lecture 12
 
lecture 8
lecture 8lecture 8
lecture 8
 
lecture 7
lecture 7lecture 7
lecture 7
 

Recently uploaded

Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxraviapr7
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeCeline George
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptxmary850239
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlDr. Bruce A. Johnson
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxSlides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxCapitolTechU
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxvidhisharma994099
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...M56BOOKSTORE PRODUCT/SERVICE
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 

Recently uploaded (20)

Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptx
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using Code
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting Bl
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
March 2024 Directors Meeting, Division of Student Affairs and Academic Support
March 2024 Directors Meeting, Division of Student Affairs and Academic SupportMarch 2024 Directors Meeting, Division of Student Affairs and Academic Support
March 2024 Directors Meeting, Division of Student Affairs and Academic Support
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxSlides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptx
 
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 

lecture 10

  • 1. CS 332: Algorithms Linear-Time Sorting Continued Medians and Order Statistics
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.