Lower Bounds & Models of Computation Jeff Edmonds York University COSC 3101 Lecture 8.

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

Lower Bounds for Sorting, Searching and Selection
Analysis of Algorithms
Lower bound: Decision tree and adversary argument
Lecture 12: Lower bounds By "lower bounds" here we mean a lower bound on the complexity of a problem, not an algorithm. Basically we need to prove that.
© The McGraw-Hill Companies, Inc., Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
© 2004 Goodrich, Tamassia Sorting Lower Bound1. © 2004 Goodrich, Tamassia Sorting Lower Bound2 Comparison-Based Sorting (§ 10.3) Many sorting algorithms.
CPSC 320: Intermediate Algorithm Design & Analysis Asymptotic Notation: (O, Ω, Θ, o, ω) Steve Wolfman 1.
Lecture 5: Linear Time Sorting Shang-Hua Teng. Sorting Input: Array A[1...n], of elements in arbitrary order; array size n Output: Array A[1...n] of the.
CS 253: Algorithms Chapter 8 Sorting in Linear Time Credit: Dr. George Bebis.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
2 -1 Analysis of algorithms Best case: easiest Worst case Average case: hardest.
© 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.
Lecture 5: Master Theorem and Linear Time Sorting
Insertion Sort for (i = 1; i < n; i++) {/* insert a[i] into a[0:i-1] */ int t = a[i]; int j; for (j = i - 1; j >= 0 && t < a[j]; j--) a[j + 1] = a[j];
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Time Complexity s Sorting –Insertion sorting s Time complexity.
Sorting Lower Bound Andreas Klappenecker based on slides by Prof. Welch 1.
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
The Complexity of Algorithms and the Lower Bounds of Problems
10/15/2002CSE More on Sorting CSE Algorithms Sorting-related topics 1.Lower bound on comparison sorting 2.Beating the lower bound 3.Finding.
1 CSE 326: Data Structures: Sorting Lecture 16: Friday, Feb 14, 2003.
Sorting Lower Bound1. 2 Comparison-Based Sorting (§ 4.4) Many sorting algorithms are comparison based. They sort by making comparisons between pairs of.
September 24, 2001 L5.1 Introduction to Algorithms Lecture 6 Prof. Shafi Goldwasser.
Insertion Sort for (int i = 1; i < a.length; i++) {// insert a[i] into a[0:i-1] int t = a[i]; int j; for (j = i - 1; j >= 0 && t < a[j]; j--) a[j + 1]
Computer Algorithms Lecture 11 Sorting in Linear Time Ch. 8
Data Structure & Algorithm Lecture 7 – Linear Sort JJCAO Most materials are stolen from Prof. Yoram Moses’s course.
CS 3343: Analysis of Algorithms
1 Time Analysis Analyzing an algorithm = estimating the resources it requires. Time How long will it take to execute? Impossible to find exact value Depends.
2IL50 Data Structures Fall 2015 Lecture 2: Analysis of Algorithms.
J. Elder COSC 3101N Thinking about Algorithms Abstractly Lecture 2. Relevant Mathematics: Classifying Functions Input Size Time f(i) = n  (n)
Analysis of Algorithms CS 477/677
Fall 2015 Lecture 4: Sorting in linear time
Asymptotic Notation (O, Ω, )
The Time Complexity of an Algorithm Specifies how the running time depends on the size of the input. CSE 3101Z Design and Analysis of Algorithms.
Sorting Algorithms Insertion Sort: Θ(n 2 ) Merge Sort:Θ(nlog(n)) Heap Sort:Θ(nlog(n)) We seem to be stuck at Θ(nlog(n)) Hypothesis: Every sorting algorithm.
COSC 3101A - Design and Analysis of Algorithms 6 Lower Bounds for Sorting Counting / Radix / Bucket Sort Many of these slides are taken from Monica Nicolescu,
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.
Spring 2015 Lecture 2: Analysis of Algorithms
Lower bounds on data stream computations Seminar in Communication Complexity By Michael Umansky Instructor: Ronitt Rubinfeld.
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.
Sorting & Lower Bounds Jeff Edmonds York University COSC 3101 Lecture 5.
Sorting and Runtime Complexity CS255. Sorting Different ways to sort: –Bubble –Exchange –Insertion –Merge –Quick –more…
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.
Lecture 2 Algorithm Analysis
David Kauchak cs062 Spring 2010
Sorting Lower Bound 4/25/2018 8:49 PM
Thinking about Algorithms Abstractly
Decision trees Polynomial-Time
CPSC 411 Design and Analysis of Algorithms
CPSC 411 Design and Analysis of Algorithms
Communication Complexity as a Lower Bound for Learning in Games
CSCE 411 Design and Analysis of Algorithms
ASU 101: The ASU Experience Computer Science Perspective
(2,4) Trees 11/15/2018 9:25 AM Sorting Lower Bound Sorting Lower Bound.
Lower Bound Theory.
Ch8: Sorting in Linear Time Ming-Te Chi
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
Chapter 11 Limitations of Algorithm Power
(2,4) Trees 2/28/2019 3:21 AM Sorting Lower Bound Sorting Lower Bound.
CPSC 411 Design and Analysis of Algorithms
David Kauchak cs302 Spring 2012
CS 583 Analysis of Algorithms
Sorting We have actually seen already two efficient ways to sort:
Presentation transcript:

Lower Bounds & Models of Computation Jeff Edmonds York University COSC 3101 Lecture 8

Lower Bounds for Sorting using Information Theory

The Time Complexity of a Problem P Merge, Quick, and Heap Sort can sort N numbers using O(N log N) comparisons between the values. Theorem: No algorithm can sort faster. The Time Complexity of a Problem P: The minimum time needed by an algorithm to solve it.

The Time Complexity of a Problem P The minimum time needed by an algorithm to solve it. Problem P is computable in time T upper (n) if there is an algorithm A which outputs the correct answer in this much time Eg: Sorting computable in T upper (n) = O(n 2 ) time.  A,  I, A(I)=P(I) and Time(A,I)  T upper (|I|) Upper Bound:

Understand Quantifiers!!! One girl Could be a separate girl for each boy. SamMary BobBeth John Marilin Monro FredAnn SamMary BobBeth John Marilin Monro FredAnn Algorithm Input  A,  I, A(I)=P(I) and Time(A,I)  T upper (|I|)

The Time Complexity of a Problem P The minimum time needed by an algorithm to solve it.  A,  I, A(I)=P(I) and Time(A,I)  T upper (|I|)  I,  A, A(I)=P(I) and Time(A,I)  T upper (|I|) What does this say? True for any problem P and time T upper. Given fixed I. Its output is P(I). Let A P(I) be the algorithm that outputs the string P(I).

The Time Complexity of a Problem P The minimum time needed by an algorithm to solve it. Time T lower (n) is a lower bound for problem p if no algorithm solve the problem faster. There may be algorithms that give the correct answer or run quickly on some inputs instance. Lower Bound:

The Time Complexity of a Problem P The minimum time needed by an algorithm to solve it. Lower Bound: Time T lower (n) is a lower bound for problem p if no algorithm solve the problem faster. Eg: No algorithm can sort N values in T lower = sqrt(N) time. But for every algorithm, there is at least one instance I for which either the algorithm gives the wrong answer or it runs in too much time.  A,  I, A(I)  P(I) or Time(A,I)  T lower (|I|)

Understand Quantifiers!!! One girl Could be a separate girl for each boy. SamMary BobBeth John Marilin Monro FredAnn SamMary BobBeth John Marilin Monro FredAnn Algorithm Input  A,  I, A(I)  P(I) or Time(A,I)  T lower (|I|)

 A,  I, A(I)=P(I) and Time(A,I)  T upper (|I|)  A,  I, A(I) ≠ P(I) or Time(A,I)  T lower (|I|) Lower Bound: Upper Bound: The Time Complexity of a Problem P The minimum time needed by an algorithm to solve it. “There is” and “there isn’t a faster algorithm” are almost negations of each other.

 A,  I, A(I)=P(I) and Time(A,I)  T upper (|I|) Upper Bound: Prover-Adversary Game I have an algorithm A that I claim works and is fast. I win if A on input I gives the correct output in the allotted time. Oh yeah, I have an input I for which it does not. What we have been doing all along.

Lower Bound: Prover-Adversary Game I win if A on input I gives the wrong output or runs slow.  A,  I, [ A(I)  P(I) or Time(A,I)  T lower (|I|)] Proof by contradiction. I have an algorithm A that I claim works and is fast. Oh yeah, I have an input I for which it does not.

Lower Bound: Prover-Adversary Game  A,  I, [ A(I)  P(I) or Time(A,I)  T lower (|I|)] I have an algorithm A that I claim works and is fast. Lower bounds are very hard to prove, because I must consider every algorithm no matter how strange.

The Yes/No Questions Game I choose a number  [1..N]. I ask you yes/no questions. Time is the number of questions asked in the worst case. I answer. I determine the number.

The Yes/No Questions Game Upper Bound 6 Great!

The Yes/No Questions Game Upper Bound Time N leaves = # of questions = height = log 2 (N)

The Yes/No Questions Game Lower Bound? Time N leaves Is there a faster algorithm? Is the third bit 1? If different questions? = # of questions = height = log 2 (N)

The Yes/No Questions Game Lower Bound? N leaves Is there a faster algorithm? If it has a different structure? Best case Worst case Time = # of questions = height = log 2 (N)

The Yes/No Questions Game Lower Bound Theorem: For every question strategy A, with the worst case object I to ask about, log 2 N questions need to be asked to determine one of N objects.  A,  I, A(I)  P(I) or Time(A,I)  log 2 N Proof: Prover/Adversary Game

Lower Bound Proof Oh yeah, I have an input I for which it does not. I have an algorithm A that I claim works and is fast. Two cases: # output leaves < N # output leaves  N

I have an algorithm A that I claim works and is fast. Man your algorithm does not have N output leaves. I win if A on input I gives the wrong output or requires log N questions. Lower Bound Proof: case 1 I give a input I = 4 with missing output.

Good now your algorithm has all N outputs as leaves. It must have height  log N. I win if A on input I gives the wrong output or requires log N questions. I have an algorithm A that I claim works and is fast. I give a input I = 5 at a deep leaf. Lower Bound Proof: case 2

The Yes/No Questions Game Lower Bound Theorem: For every question strategy A, with the worst case object I to ask about, log 2 N questions need to be asked to determine one of N objects.  A,  I, A(I)  P(I) or Time(A,I)  log 2 N Proof: Prover/Adversary Game End of Proof.

Communication Complexity Or a obj  a set of N objs. Time is the number of bits sent in the worst case. I send you a stream of bits. I determine the object. I choose a number  [1..N].

Communication Complexity Upper Bound 6 Great!

Communication Complexity Lower Bound Theorem: For every communication strategy A, with the worst case object I to communicate, log 2 N bits need to transmitted to communicate one of N objects.  A,  I, A(I)  P(I) or Time(A,I)  log 2 N

The Sorting Game I choose a permutation of {1,2,3,…,N}. I ask you yes/no questions. Time is the number of questions asked in the worst case. I answer. I determine the permuation.

Sorting Upper Bound b,c,a Great!

Time N! leaves = # of questions = height = log 2 (N!) Sorting Upper Bound

N! = 1 × 2 × 3 × … × N / 2 × … × N N factors each at most N. N / 2 factors each at least N / 2.  N N N / 2  N/2N/2 Bounding log(N!) N / 2 log( N / 2 )  log(N!)  N log(N) =  (N log(N)).

Time N! leaves = # of questions = height = log 2 (N!) =  (N log(N)). Is there a faster algorithm? Is the third bit of c 1? If different questions? Sorting Lower Bound

class InsertionSortAlgorithm { for (int i = 1; i < a.length; i++) { int j = i; while ((j > 0) && (a[j-1] > a[i])) { a[j] = a[j-1]; j--; } a[j] = B; }} Is there a faster algorithm? If different model of computation? Sorting Lower Bound

Sorting Lower Bound Theorem: For every sorting algorithm A, with the worst case input instance I,  (N log 2 N) comparisons (or other bit operations) need to be executed to sort N objects.  A,  I, A(I)  P(I) or Time(A,I)  N log 2 N Proof: Prover/Adversary Game

Lower Bound Proof Oh yeah, I will find an input I for which it does not. I have an algorithm A that I claim works and is fast. class InsertionSortAlgorithm { for (int i = 1; i < a.length; i++) { int j = i; while ((j > 0) && (a[j-1] > a[i])) { a[j] = a[j-1]; j--; } a[j] = B; }}

Lower Bound Proof I have an algorithm A that I claim works and is fast. class InsertionSortAlgorithm { for (int i = 1; i < a.length; i++) { int j = i; while ((j > 0) && (a[j-1] > a[i])) { a[j] = a[j-1]; j--; } a[j] = B; }} But first let me translate your algorithm into a decision tree.

I choose a permutation of {1,2,3,…,N}. I answer. I determine the permuation. class InsertionSortAlgorithm { for (int i = 1; i < a.length; i++) { int j = i; while ((j > 0) && (a[j-1] > a[i])) { a[j] = a[j-1]; j--; } a[j] = B; }} I ask you this yes/no question. I run my algorithm until I need to know something about the input permutation. Lower Bound Proof

class InsertionSortAlgorithm { for (int i = 1; i < a.length; i++) { int j = i; while ((j > 0) && (a[j-1] > a[i])) { a[j] = a[j-1]; j--; } a[j] = B; }} Lower Bound Proof

Oh yeah, I have an input I for which it does not. I have an algorithm A that I claim works and is fast. Two cases: # output leaves < N! # output leaves  N!

I have an algorithm A that I claim works and is fast. Man your algorithm does not have N! output leaves. I win if A on input I gives the wrong output or requires log N questions. Lower Bound Proof: case 1 I give a input I = with missing output.

Good now your algorithm has all N! outputs as leaves. It must have height  log N!. I win if A on input I gives the wrong output or requires log N! questions. I have an algorithm A that I claim works and is fast. Lower Bound Proof: case 2 I give a input I = at a deep leaf. =  (N log(N)).

Sorting Lower Bound Theorem: For every sorting algorithm A, on the worst case input instance I,  (N log 2 N) comparisons (or other bit operations) need to be executed to sort N objects.  A,  I, A(I)  P(I) or Time(A,I)  N log 2 N Proof: Prover/Adversary Game End of Proof.

End