CS420 lecture three Lowerbounds wim bohm, cs CSU.

Slides:



Advertisements
Similar presentations
Algorithms Algorithm: what is it ?. Algorithms Algorithm: what is it ? Some representative problems : - Interval Scheduling.
Advertisements

110/6/2014CSE Suprakash Datta datta[at]cse.yorku.ca CSE 3101: Introduction to the Design and Analysis of Algorithms.
MATH 224 – Discrete Mathematics
Analysis of Algorithms
Lower bound: Decision tree and adversary argument
Lower Bounds & Models of Computation Jeff Edmonds York University COSC 3101 Lecture 8.
Lower bound for sorting, radix sort COMP171 Fall 2005.
CS420 lecture one Problems, algorithms, decidability, tractability.
© The McGraw-Hill Companies, Inc., Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Deterministic Selection and Sorting Prepared by John Reif, Ph.D. Analysis of Algorithms.
Using Divide and Conquer for Sorting
CPSC 320: Intermediate Algorithm Design & Analysis Asymptotic Notation: (O, Ω, Θ, o, ω) Steve Wolfman 1.
Lower bound for sorting, radix sort COMP171 Fall 2006.
1 ICS 353 Design and Analysis of Algorithms Spring Semester (062) King Fahd University of Petroleum & Minerals Information & Computer Science.
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.
Asymptotic Growth Rate
CS 253: Algorithms Chapter 8 Sorting in Linear Time Credit: Dr. George Bebis.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 4 Comparison-based sorting Why sorting? Formal analysis of Quick-Sort Comparison.
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.
Sorting. Introduction Assumptions –Sorting an array of integers –Entire sort can be done in main memory Straightforward algorithms are O(N 2 ) More complex.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
CS420 lecture two Fundamentals
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
The Complexity of Algorithms and the Lower Bounds of Problems
Sorting Lower Bound1. 2 Comparison-Based Sorting (§ 4.4) Many sorting algorithms are comparison based. They sort by making comparisons between pairs of.
Aaron Bernstein Analysis of Algorithms I. Sorting Algorithms Insertion Sort: Θ(n 2 ) Merge Sort:Θ(nlog(n)) Heap Sort:Θ(nlog(n)) We seem to be stuck at.
CSCE350 Algorithms and Data Structure
Lecture 2 Computational Complexity
Mathematics Review and Asymptotic Notation
CS 3343: Analysis of Algorithms
1 Chapter 1 Analysis Basics. 2 Chapter Outline What is analysis? What to count and consider Mathematical background Rates of growth Tournament method.
Order Statistics. Order statistics Given an input of n values and an integer i, we wish to find the i’th largest value. There are i-1 elements smaller.
The Lower Bounds of Problems
CS 61B Data Structures and Programming Methodology July 28, 2008 David Sun.
Asymptotic Analysis-Ch. 3
Sorting Conclusions David Kauchak cs302 Spring 2013.
Algorithm Analysis CS 400/600 – Data Structures. Algorithm Analysis2 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely.
Chapter 2 Computational Complexity. Computational Complexity Compares growth of two functions Independent of constant multipliers and lower-order effects.
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.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 1. Complexity Bounds.
LIMITATIONS OF ALGORITHM POWER
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 CSC 421: Algorithm Design & Analysis Spring 2014 Complexity & lower bounds  brute force  decision trees  adversary arguments  problem reduction.
Lecture 14 Lower Bounds Decision tree model Linear-time reduction.
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
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.
David Kauchak cs062 Spring 2010
Decision trees Polynomial-Time
The Growth of Functions
CPSC 411 Design and Analysis of Algorithms
Enough Mathematical Appetizers!
Computation.
(2,4) Trees 11/15/2018 9:25 AM Sorting Lower Bound Sorting Lower Bound.
Lower Bound Theory.
(2,4) Trees 12/4/2018 1:20 PM Sorting Lower Bound Sorting Lower Bound.
CS 2210 Discrete Structures Algorithms and Complexity
Applied Discrete Mathematics Week 6: Computation
Linear Sorting Sorting in O(n) Jeff Chastine.
The Lower Bounds of Problems
Counting Discrete Mathematics.
(2,4) Trees 2/28/2019 3:21 AM Sorting Lower Bound Sorting Lower Bound.
Topic 5: Heap data structure heap sort Priority queue
Lower bound for sorting, radix sort
CPSC 411 Design and Analysis of Algorithms
David Kauchak cs302 Spring 2012
CS210- Lecture 2 Jun 2, 2005 Announcements Questions
Presentation transcript:

CS420 lecture three Lowerbounds wim bohm, cs CSU

Big O, big omega, big theta f(x) = O(g(x)) iff there are positive integers c and n 0 such that f(x) n 0 f(x) = Ω(g(x)) iff there are positive integers c and n 0 such that f(x) > c.g(x) for all x > n 0 f(x) = Θ(g(x)) iff f(x) = O(g(x)) and f(x) = Ω(g(x))

Big O etc. Big O used in upper bounds, ie the worst or average case complexity of an algorithm. Big theta is a tight bound, eg stronger than upper bound. Big omega used in lower bounds, ie the complexity of a problem.

lower bounds An easy lower bound on a problem is the size of the output it needs to produce, or the number of inputs it has to access – Generate all permutations of size n, lower bound? – Towers of Hanoi, lower bound? – Sum n input integers, lower bound? but... sum integers 1 to n?

some Ω(n) problems Given an unsorted array A and a number p, rearrange A such that all A[i] x

some Ω(n) problems Given an unsorted array A and a number x, rearrange A such that all A[i] =x L=1; R=n; while(L<R){ while((A[L]<=x)&&(L<R)L++ while((A[R]>=x)&&(L<R))R- - if(L<R)swap(A,L,R) }

Dutch National Flag

flag

Comparison problems We have seen search.

Comparison problems We have seen search. Why is it closed?

Comparison problems We have seen search. Why is it Ω(logn)?

Comparison problems We have seen search. What are the allowed operations?

Comparison problems We have seen search. Why is the decision tree binary?

Comparison problems We have seen search. At least how many leaves?

Comparison problems We have seen search. At least how high? Why?

Comparison problems Let's try the same for sort we have an O(n logn) upper bound what would be the allowed steps?

Comparison problems Let's try the same for sort we have an O(n logn) upper bound comparison, array element assignment, index arithmetic, establish sorted

Comparison problems Let's try the same for sort we have an O(n logn) upper bound is the decision tree binary again?

Comparison problems Let's try the same for sort we have an O(n logn) upper bound how many leaves this time?

Comparison problems Let's try the same for sort we have an O(n logn) upper bound every leaf represents a specific permutation of the array

Comparison problems Let's try the same for sort we have an O(n logn) upper bound how many different permutations?

Comparison problems Let's try the same for sort we have an O(n logn) upper bound n! how high will the decision tree at least be?

Comparison problems Let's try the same for sort we have an O(n logn) upper bound the decision tree will be at least log(n!) high log(n!) = O(nlogn) so sort is Ω(nlogn), and thus closed.

Tournaments Selecting the maximum element of an array. View it as a tournament. Comparison is a match, winning is transitive: – A>B and B>C implies A>C, so A does not need to play C, and B and C can never be the winner of the tournament Many possible O(n) algorithms tennis(S): if (|S|==1) S 1 else max(tennis(topHalf(S)), tennis(bottomHalf(S))) sweep(S): winner= S 1 for i=2 to n winner = max(winner,S i )

Runner up a b c d e f g h b a d c f e h g tennis sweep which gives more info about runner up?

Assumptions about initial input Transitive and total ordering – transitive: a>b and b>c implies a>c (no roshambo) – total: for all a and b: either a>b or b>a – ie the elements can be ranked Any assignment of ranks to names is feasible – in previous example we could assign any of the 8! permutations of rankings 1 to 8 to a to h Because we look for the winner, anyone who loses stops playing. Therefore there will be n-1 (n is number of inputs) games / comparisons for any tournament – notice: both sweep and tennis have 7 matches

Simpler case: n=4 Any of the 24 assignments of 1..4 to a..d is valid Build a decision tree for sweep (for n = 4), which is sometimes called "caterpillar"

Decision tree for sweep Any of the 24 assignments of 1..4 to a..d is valid Build a decision tree for sweep (for n = 4) a:b b a a:c c a b:c c b c:d d c b:d d b c:d d c a:d d a

Decision tree for sweep Any of the 24 assignments of 1..4 to a..d is valid Build a decision tree for sweep (for n = 4) a:b b a a:c c a b:c c b c:d d c b:d d b c:d d c a:d d a what do we know about the runner up for this outcome?

Decision tree for sweep Any of the 24 assignments of 1..4 to a..d is valid Build a decision tree for sweep (for n = 4) a:b b a a:c c a b:c c b c:d d c b:d d b c:d d c a:d d a what do we know about the runner up for this outcome?

tennis Build a decision tree for tennis (for n = 4)

Decision tree for tennis Build a decision tree for tennis (for n = 4) a:b b a c:d d c d c b:d d b b:c c b a:d d a a:c c a

Decision tree for tennis Build a decision tree for tennis (for n = 4) a:b b a c:d d c d c b:d d b b:c c b a:d d a a:c c a what do we know about the runner up for this outcome?

Decision tree for tennis Build a decision tree for tennis (for n = 4) a:b b a c:d d c d c b:d d b b:c c b a:d d a a:c c a what do we know about the runner up for this outcome?

Runner up In “The Art of Computer Programming, vol 3”, Donald Knuth proved that the tennis tournament algorithm provides the lower bound to determine the runner up: In the case of tennis we need lg n more comparisons to find the runner up