1 CSC 421: Algorithm Design & Analysis Spring 2014 Complexity & lower bounds  brute force  decision trees  adversary arguments  problem reduction.

Slides:



Advertisements
Similar presentations
110/6/2014CSE Suprakash Datta datta[at]cse.yorku.ca CSE 3101: Introduction to the Design and Analysis of Algorithms.
Advertisements

Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Lower Bounds for Sorting, Searching and Selection
Lower bound: Decision tree and adversary argument
Lower bound for sorting, radix sort COMP171 Fall 2005.
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.
CS420 lecture one Problems, algorithms, decidability, tractability.
Transform & Conquer Replacing One Problem With Another Saadiq Moolla.
Lectures on Recursive Algorithms1 COMP 523: Advanced Algorithmic Techniques Lecturer: Dariusz Kowalski.
CSCE 3110 Data Structures & Algorithm Analysis
Chapter 6: Transform and Conquer
Algorithms Recurrences. Definition – a recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs Example.
Finding the Median Algorithm : Design & Analysis [11]
CPSC 320: Intermediate Algorithm Design & Analysis Asymptotic Notation: (O, Ω, Θ, o, ω) Steve Wolfman 1.
CSC 2300 Data Structures & Algorithms March 27, 2007 Chapter 7. Sorting.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
© 2004 Goodrich, Tamassia Sorting Lower Bound1. © 2004 Goodrich, Tamassia Sorting Lower Bound2 Comparison-Based Sorting (§ 10.3) Many sorting algorithms.
Chapter 11: Limitations of Algorithmic Power
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Sorting Lower Bound1. 2 Comparison-Based Sorting (§ 4.4) Many sorting algorithms are comparison based. They sort by making comparisons between pairs of.
Induction and recursion
CSE 373 Data Structures Lecture 15
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.
1 CSC 421: Algorithm Design & Analysis Spring 2013 Complexity & Computability  lower bounds on problems brute force, decision trees, adversary arguments,
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
CSCE350 Algorithms and Data Structure
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
Analysis of Algorithms
1 CSC 421: Algorithm Design Analysis Spring 2014 Transform & conquer  transform-and-conquer approach  presorting  balanced search trees, heaps  Horner's.
The Lower Bounds of Problems
Sorting Fun1 Chapter 4: Sorting     29  9.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
CSC 213 Lecture 13: Writing Code & Sorting Lowest Bound.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
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.
Limits to Computation How do you analyze a new algorithm? –Put it in the form of existing algorithms that you know the analysis. –For example, given 2.
Solving Recurrences with the Substitution Method.
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.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
BY Lecturer: Aisha Dawood. A recurrence is a function is defined in terms of:  one or more base cases, and  itself, with smaller arguments. 2.
Big O David Kauchak cs302 Spring Administrative Assignment 1: how’d it go? Assignment 2: out soon… Lab code.
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.
1 CSC 421: Algorithm Design Analysis Spring 2013 Transform & conquer  transform-and-conquer approach  presorting  balanced search trees, heaps  Horner's.
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.
CSC 421: Algorithm Design & Analysis
Decision trees Polynomial-Time
Chapter 6 Transform-and-Conquer
CPSC 411 Design and Analysis of Algorithms
CSC 421: Algorithm Design & Analysis
Growth of functions CSC317.
(2,4) Trees 11/15/2018 9:25 AM Sorting Lower Bound Sorting Lower Bound.
Chapter 6 Transform and Conquer.
Lower Bound Theory.
Analysis and design of algorithm
CSCE 411 Design and Analysis of Algorithms
(2,4) Trees 12/4/2018 1:20 PM Sorting Lower Bound Sorting Lower Bound.
Divide-and-Conquer 7 2  9 4   2   4   7
Chapter 6: Transform and Conquer
Chapter 11 Limitations of Algorithm Power
(2,4) Trees 2/28/2019 3:21 AM Sorting Lower Bound Sorting Lower Bound.
Divide-and-Conquer 7 2  9 4   2   4   7
CPSC 411 Design and Analysis of Algorithms
CSC 421: Algorithm Design & Analysis
Complexity Theory: Foundations
Presentation transcript:

1 CSC 421: Algorithm Design & Analysis Spring 2014 Complexity & lower bounds  brute force  decision trees  adversary arguments  problem reduction

2 Lower bounds when studying a problem, may wish to establish a lower bound on efficiency  binary search is O(log N) – can we do better?  merge/quick/heap sorts are O(N log N) – can we do better? establishing a lower bound can tell us  when a particular algorithm is as good as possible  when the problem is intractable (by showing that best possible algorithm is BAD) methods for establishing lower bounds:  brute force  information-theoretic arguments (decision trees)  adversary arguments  problem reduction

Brute force arguments sometimes, a problem-specific approach works example: polynomial evaluationp(n) = a n x n + a n-1 x n-1 + … + a 0  requires Ω(N) steps, since each coefficient must be processed example: Towers of Hanoi puzzle  can prove, by induction, that moving a tower of size N requires Ω(2 N ) steps 3

Information-theoretic arguments can sometimes establish a lower bound based on the amount of information the solution must produce example: guess a randomly selected number between 1 and N  with possible responses of "correct", "too low", or "too high"  the amount of uncertainty is  log 2 N , the number of bits needed to specify the selected largest number e.g., N = 127  7 bits  each answer to a question yields at most 1 bit of information if guess of 64 yields “too high,” then 1 st bit must be a 0  0xxxxxx if next guess of 32 yields “too low,”, then 2 nd bit must be 1  01xxxxx if next guess of 48 yields “too low,” then 3 rd bit must be 1  011xxxx...  thus,  log 2 N  is a lower bound on the number of questions 4

Decision trees a useful structure for information-theoretic arguments is a decision tree example: guessing a number between 1 and ? 4?12? 2?6? high? 0xxx low? 1xxx high? 00xx low? 01xx high? 10xx low? 11xx high? 0001 low? high? 0101 low? ?14? high? 1001 low? high? 1101 low?

6 Decision trees in general, a decision tree is a model of algorithms involving comparisons  internal nodes represent comparisons  leaves represent outcomes e.g., decision tree for 3-element insertion sort:

7 Decision trees & sorting note that any comparison-based sorting algorithm can be represented by a decision tree  number of leaves (outcomes)  N!  height of binary tree with N! leaves   log 2 N!   therefore, the minimum number of comparisons required by any comparison-based sorting algorithm   log 2 N!   since  log 2 N!   N log 2 N ( proof not shown ), the lower bound Ω(N log N) is tight thus, merge/quick/heap sorts are as good as it gets

8 Decision trees & searching similarly, we can use a decision tree to show that binary search is as good as it gets (assuming the list is sorted) decision tree for binary search of 4-element list:  internal nodes are found elements  leaves are ranges if not found  number of leaves (ranges where not found) = N + 1  height of binary tree with N+1 leaves   log 2 (N+1)   therefore, the minimum number of comparisons required by any comparison-based searching algorithm   log 2 (N+1)   lower bound Ω(log N) is tight

9 Adversary arguments using an adversary argument, you repeatedly adjust the input to make an algorithm work the hardest example: dishonest hangman  adversary always puts the word in a larger of the subset generated by last guess  for a given dictionary, can determine a lower bound on guesses example: merging two sorted lists of size N (as in merge sort)  adversary makes it so that no list "runs out" of values (e.g., a i < b j iff i < j)  forces 2N-1 comparisons to produce b 1 < a 1 < b 2 < a 2 < … < b N < a N

10 Problem reduction problem reduction uses a transform & conquer approach  if we can show that problem P is at least as hard as problem Q, then a lower bound for Q is also a lower bound for P. in general, to prove lower bound for P: 1.find problem Q with a known lower bound 2.reduce that problem to problem P i.e., show that can solve Q by solving an instance of P 3.then P is at least as hard as Q, so same lower bound applies example: prove that multiplication (of N-bit numbers) is Ω(N) 1.squaring an N-bit number is known to be Ω(N) 2.can reduce squaring to multiplication: x 2 = x * x 3.then multiplication is at least as hard as squaring, so also Ω(N) (proof by contradiction) assume multiplication can be solved in O(X) where X < N then could square a number by multiplying it with itself  O(X) < O(N) CONTRADICTION

Problem reduction example CLOSEST NUMBERS (CN) PROBLEM: given N numbers, find the two closest numbers 1.consider the ELEMENT UNIQUENESS (EU) problem  given a list of N numbers, determine if all are unique (no dupes)  this problem has been shown to have a lower bound of Ω(N log N) 2.can reduce EU to CN consider an instance of EU: given numbers e 1, …, e N, determine if all are unique  find the two closest numbers (this is an instance of CN)  if the distance between them is > 0, then e 1, …, e N are unique 3.this shows that CN is at least as hard as EU  can solve an instance of EU by performing a transformation & solving CN  since transformation is O(N), CN must also have a lower-bound of Ω(N log N) (proof by contradiction) assume CN could be solved in O(X) where X < N log N then, could solve EU by transforming & solving CN  O(N) +O(X) < O(N log N) CONTRADICTION 11

Another example CLOSEST POINTS (CP) PROBLEM: given N points in the plane, find the two closest points 1.consider the CLOSEST NUMBER (CN) problem  we just showed that CN has a lower bound of Ω(N log N) 2.can reduce CN to CP consider an instance of CN: given numbers e 1, …, e N, determine closest numbers  from these N numbers, construct N points: (e 1, 0), …, (e N, 0)  find the two closest points (this is an instance of CP)  if (e i, 0) and (e j, 0) are closest points, then e i and e j are closest numbers 3.this shows that CP is at least as hard as CN  can solve an instance of CN by performing a transformation & solving CP  since transformation is O(N), CP must also have a lower-bound of Ω(N log N) (proof by contradiction) assume CP could be solved in O(X) where X < N log N then, could solve EU by transforming & solving CP  O(N) +O(X) < O(N log N) this contradicts what we know about EU, so CP must be Ω(N log N) 12

Tightness note: if an algorithm is Ω(N log N), then it is also Ω(N) are the Ω(N log N) lower bounds tight for CLOSEST NUMBERS and CLOSEST POINTS problems?  can you devise O(N log N) algorithm for CLOSEST NUMBERS?  can you devise O(N log N) algorithm for CLOSEST POINTS? 13