© 2004 Goodrich, Tamassia Sorting Lower Bound1. © 2004 Goodrich, Tamassia Sorting Lower Bound2 Comparison-Based Sorting (§ 10.3) Many sorting algorithms.

Slides:



Advertisements
Similar presentations
CPSC 411 Design and Analysis of Algorithms Set 2: Sorting Lower Bound Prof. Jennifer Welch Spring 2011 CPSC 411, Spring 2011: Set 2 1.
Advertisements

Heapsort O(n lg n) worst case Another design paradigm –Use of a data structure (heap) to manage information during execution of algorithm Comparision-based.
CSE332: Data Abstractions Lecture 14: Beyond Comparison Sorting Dan Grossman Spring 2010.
© 2004 Goodrich, Tamassia Merge Sort1 7 2  9 4   2  2 79  4   72  29  94  4.
Data Structures Lecture 9 Fang Yu Department of Management Information Systems National Chengchi University Fall 2010.
Lower bound for sorting, radix sort COMP171 Fall 2005.
Merge Sort 7 2  9 4   2  2 79  4   72  29  94  4.
Merge Sort 4/15/2017 4:30 PM Merge Sort 7 2   7  2  2 7
Using Divide and Conquer for Sorting
Merge Sort1 Part-G1 Merge Sort 7 2  9 4   2  2 79  4   72  29  94  4.
Merge Sort1 7 2  9 4   2  2 79  4   72  29  94  4.
Insertion Sort. Selection Sort. Bubble Sort. Heap Sort. Merge-sort. Quick-sort. 2 CPSC 3200 University of Tennessee at Chattanooga – Summer 2013 © 2010.
© 2004 Goodrich, Tamassia Quick-Sort     29  9.
1 Sorting Problem: Given a sequence of elements, find a permutation such that the resulting sequence is sorted in some order. We have already seen: –Insertion.
Quick-Sort     29  9.
© 2004 Goodrich, Tamassia Quick-Sort     29  9.
Lower bound for sorting, radix sort COMP171 Fall 2006.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 4 Comparison-based sorting Why sorting? Formal analysis of Quick-Sort Comparison.
© 2004 Goodrich, Tamassia Sorting Lower Bound1. © 2004 Goodrich, Tamassia Sorting Lower Bound2 Comparison-Based Sorting (§ 10.3) Many sorting algorithms.
CPSC 411, Fall 2008: Set 2 1 CPSC 411 Design and Analysis of Algorithms Set 2: Sorting Lower Bound Prof. Jennifer Welch Fall 2008.
CPSC 411, Fall 2008: Set 2 1 CPSC 311 Analysis of Algorithms Sorting Lower Bound Prof. Jennifer Welch Fall 2009.
© 2004 Goodrich, Tamassia Heaps © 2004 Goodrich, Tamassia Heaps2 Priority Queue Sorting (§ 8.1.4) We can use a priority queue to sort a set.
TTIT33 Algorithms and Optimization – Dalg Lecture 2 HT TTIT33 Algorithms and optimization Lecture 2 Algorithms Sorting [GT] 3.1.2, 11 [LD] ,
CSE 326: Data Structures Sorting Ben Lerner Summer 2007.
Sorting Lower Bound Andreas Klappenecker based on slides by Prof. Welch 1.
1 Today’s Material Lower Bounds on Comparison-based Sorting Linear-Time Sorting Algorithms –Counting Sort –Radix Sort.
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
Sorting Lower Bound1. 2 Comparison-Based Sorting (§ 4.4) Many sorting algorithms are comparison based. They sort by making comparisons between pairs of.
Lower Bounds for Comparison-Based Sorting Algorithms (Ch. 8)
CSC 213 – Large Scale Programming. Today’s Goals  Review past discussion of data sorting algorithms  Weaknesses of past approaches & when we use them.
Sorting in Linear Time Lower bound for comparison-based sorting
CSE 373 Data Structures Lecture 15
1 More Sorting radix sort bucket sort in-place sorting how fast can we sort?
CSC 213 Lecture 12: Quick Sort & Radix/Bucket Sort.
CSE373: Data Structures & Algorithms Lecture 20: Beyond Comparison Sorting Dan Grossman Fall 2013.
Sorting Fun1 Chapter 4: Sorting     29  9.
Fall 2015 Lecture 4: Sorting in linear time
Sorting Lower Bounds Amihood Amir Bar-Ilan University 2014.
CSC 213 Lecture 13: Writing Code & Sorting Lowest Bound.
Princeton University COS 423 Theory of Algorithms Spring 2001 Kevin Wayne Average Case Analysis.
1 CSE 326: Data Structures A Sort of Detour Henry Kautz Winter Quarter 2002.
© 2004 Goodrich, Tamassia Quick-Sort     29  9.
© 2004 Goodrich, Tamassia Merge Sort1 7 2  9 4   2  2 79  4   72  29  94  4.
Sorting 1. Insertion Sort
CSCE 411H Design and Analysis of Algorithms Set 10: Lower Bounds Prof. Evdokia Nikolova* Spring 2013 CSCE 411H, Spring 2013: Set 10 1 * Slides adapted.
1 Merge Sort 7 2  9 4   2  2 79  4   72  29  94  4.
QuickSort by Dr. Bun Yue Professor of Computer Science CSCI 3333 Data.
Sorting Lower Bounds n Beating Them. Recap Divide and Conquer –Know how to break a problem into smaller problems, such that –Given a solution to the smaller.
Lecture 3 Sorting and Selection. Comparison Sort.
SORTING AND ASYMPTOTIC COMPLEXITY Lecture 13 CS2110 – Fall 2009.
1 Chapter 8-1: Lower Bound of Comparison Sorts. 2 About this lecture Lower bound of any comparison sorting algorithm – applies to insertion sort, selection.
Chapter 11 Sorting Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and Mount.
David Kauchak cs062 Spring 2010
Sorting Lower Bound 4/25/2018 8:49 PM
Decision trees Polynomial-Time
CPSC 411 Design and Analysis of Algorithms
CPSC 411 Design and Analysis of Algorithms
Objectives Introduce different known sorting algorithms
CSCE 411 Design and Analysis of Algorithms
(2,4) Trees 11/15/2018 9:25 AM Sorting Lower Bound Sorting Lower Bound.
Analysis of Algorithms
CSCE 411 Design and Analysis of Algorithms
(2,4) Trees 12/4/2018 1:20 PM Sorting Lower Bound Sorting Lower Bound.
CS200: Algorithm Analysis
Linear Sorting Sorting in O(n) Jeff Chastine.
(2,4) Trees 2/28/2019 3:21 AM Sorting Lower Bound Sorting Lower Bound.
Lower bound for sorting, radix sort
Copyright © Aiman Hanna All rights reserved
CPSC 411 Design and Analysis of Algorithms
David Kauchak cs302 Spring 2012
Presentation transcript:

© 2004 Goodrich, Tamassia Sorting Lower Bound1

© 2004 Goodrich, Tamassia Sorting Lower Bound2 Comparison-Based Sorting (§ 10.3) Many sorting algorithms are comparison based. They sort by making comparisons between pairs of objects Examples: bubble-sort, selection-sort, insertion-sort, heap-sort, merge-sort, quick-sort,... Let us therefore derive a lower bound on the running time of any algorithm that uses comparisons to sort n elements, x 1, x 2, …, x n. Is x i < x j ? yes no

© 2004 Goodrich, Tamassia Sorting Lower Bound3 Counting Comparisons Let us just count comparisons then. Each possible run of the algorithm corresponds to a root-to-leaf path in a decision tree

© 2004 Goodrich, Tamassia Sorting Lower Bound4 Decision Tree Height The height of this decision tree is a lower bound on the running time Every possible input permutation must lead to a separate leaf output. If not, some input …4…5… would have same output ordering as …5…4…, which would be wrong. Since there are n!=1*2*…*n leaves, the height is at least log (n!)

© 2004 Goodrich, Tamassia Sorting Lower Bound5 The Lower Bound Any comparison-based sorting algorithms takes at least log (n!) time Therefore, any such algorithm takes time at least log(n!) = log 1 + log 2 + … + log n >= (n log n )/2 (by concavity, or integration) That is, any comparison-based sorting algorithm must require at least  (n log n) time.

© 2004 Goodrich, Tamassia Sorting Lower Bound6 Summary of Sorting Algorithms AlgorithmTimeNotes selection-sort O(n2)O(n2) in-place slow (good for small inputs) insertion-sort O(n2)O(n2) in-place slow (good for small inputs) quick-sort O(n log n) expected in-place, randomized fastest (good for large inputs) heap-sort O(n log n) in-place fast (good for large inputs) merge-sort O(n log n) sequential data access fast (good for huge inputs)