24-Jun-15 Pruning. 2 Exponential growth How many leaves are there in a complete binary tree of depth N? This is easy to demonstrate: Count “going left”

Slides:



Advertisements
Similar presentations
Introduction to Algorithms NP-Complete
Advertisements

18-Dec-14 Pruning. 2 Exponential growth How many leaves are there in a complete binary tree of depth N? This is easy to demonstrate: Count “going left”
BackTracking Algorithms
Chapter 4: Trees Part II - AVL Tree
Types of Algorithms.
Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
Games & Adversarial Search
Discrete Structure Li Tak Sing( 李德成 ) Lectures
Sum of Subsets and Knapsack
Complexity 11-1 Complexity Andrei Bulatov Space Complexity.
CS 206 Introduction to Computer Science II 09 / 10 / 2008 Instructor: Michael Eckmann.
C++ Programming:. Program Design Including
Heapsort. 2 Why study Heapsort? It is a well-known, traditional sorting algorithm you will be expected to know Heapsort is always O(n log n) Quicksort.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
CS420 lecture ten BACKTRACK. Solution vectors In optimization problems, or more general in search problems, a set of choices are to be made to arrive.
Constraint Satisfaction Problems
CS 206 Introduction to Computer Science II 10 / 14 / 2009 Instructor: Michael Eckmann.
LEARNING DECISION TREES
Tirgul 6 B-Trees – Another kind of balanced trees Problem set 1 - some solutions.
Chapter 11: Limitations of Algorithmic Power
Ch 13 – Backtracking + Branch-and-Bound
CS 206 Introduction to Computer Science II 02 / 11 / 2009 Instructor: Michael Eckmann.
Games & Adversarial Search Chapter 6 Section 1 – 4.
Ref: Pfleeger96, Ch.31 NP-Complete Problems Reference: Pfleeger, Charles P., Security in Computing, 2nd Edition, Prentice Hall, 1996.
Backtracking.
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.
1 COP 3538 Data Structures with OOP Chapter 8 - Part 2 Binary Trees.
Difficult Problems. Polynomial-time algorithms A polynomial-time algorithm is an algorithm whose running time is O(f(n)), where f(n) is a polynomial A.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Quantified Formulas - Decision Procedure Daniel Kroening, Ofer Strichman Presented by Changki Hong 07 NOV 08.
Heapsort CSC Why study Heapsort? It is a well-known, traditional sorting algorithm you will be expected to know Heapsort is always O(n log n)
Design and Analysis of Algorithms - Chapter 111 How to tackle those difficult problems... There are two principal approaches to tackling NP-hard problems.
Chapter 12 Coping with the Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Space Complexity. Reminder: P, NP classes P NP is the class of problems for which: –Guessing phase: A polynomial time algorithm generates a plausible.
Contents of Chapter 7 Chapter 7 Backtracking 7.1 The General method
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
CSE332: Data Abstractions Lecture 24.5: Interlude on Intractability Dan Grossman Spring 2012.
Recursive Back Tracking & Dynamic Programming Lecture 7.
Adversarial Games. Two Flavors  Perfect Information –everything that can be known is known –Chess, Othello  Imperfect Information –Player’s have each.
Types of Algorithms. 2 Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification.
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 7Sept 20, 2005Carnegie.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
CSE 143 Lecture 13 Recursive Backtracking slides created by Ethan Apter
Analysis & Design of Algorithms (CSCE 321)
CSCE350 Algorithms and Data Structure Lecture 21 Jianjun Hu Department of Computer Science and Engineering University of South Carolina
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
HW4: sites that look like transcription start sites Nucleotide histogram Background frequency Count matrix for translation start sites (-10 to 10) Frequency.
1 CSC 384 Lecture Slides (c) , C. Boutilier and P. Poupart CSC384: Lecture 16  Last time Searching a Graphplan for a plan, and relaxed plan heuristics.
Space Complexity. Reminder: P, NP classes P is the class of problems that can be solved with algorithms that runs in polynomial time NP is the class of.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
Constraint Satisfaction Problems
Recursive Objects (Part 4)
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Types of Algorithms.
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Dr. David Matuszek Heapsort Dr. David Matuszek
Back Tracking.
Types of Algorithms.
Brute Force Approaches
Heapsort.
Artificial Intelligence
Pruning 24-Feb-19.
Backtracking and Branch-and-Bound
Types of Algorithms.
Heapsort.
Heapsort.
CO 303 Algorithm Analysis and Design
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

24-Jun-15 Pruning

2 Exponential growth How many leaves are there in a complete binary tree of depth N? This is easy to demonstrate: Count “going left” as a 0 Count “going right” as a 1 Each leaf represents one of the 2 N possible N-bit binary numbers This observation turns out to be very useful in certain kinds of problems depth = 0, count = 1 depth = 1, count = 2 depth = 2, count = 4 depth = 3, count = 8 depth = 4, count = 16 depth = N, count = 2 N

3 Pruning Suppose the binary tree represents a problem that we have to explore to find a solution (or goal node) If we can prune (decide we can ignore) a part of the tree, we save effort The higher up in the tree we can prune, the more effort we can save The advantage is exponential saves 3 saves 7 saves 15

4 Sum of subsets Problem: There are n positive integers, and a positive integer W Find a subset of the integers that sum to exactly W Example: The numbers are 2, 5, 7, 8, 13 Find a subset of numbers that sum to exactly 25 We can multiply each number by 1 if it is in the sum, 0 if it is not              25

5 Brute force We have a brute-force method for solving the sum of subsets problem For N numbers, count in binary from 0 to 2 N For each 1, include the corresponding number; for each 0, exclude the corresponding number Stop if we get lucky This is clearly an exponential-time algorithm It seems like, with a little cleverness, we could do better It turns out that we can use pruning to do somewhat better But we are still left with an exponential-time algorithm

6 Binary tree representation Suppose our numbers are 3, 8, 9, 17, 26, 39, 43, 56 and our goal is 100 We can describe this as a binary tree search As we search the binary tree, A node is promising if we might be able to get to a solution from it A node is nonpromising if we know we can’t get to a solution When we detect a nonpromising node, we can prune (ignore) the entire subtree rooted at that node How do we detect nonpromising nodes? 3 (yes or no) 8 (yes or no) 9 (yes or no) 17 (yes or no) etc.

7 Detecting nonpromising nodes Suppose we work from left to right in the sequence That is, we try things in the order When we get to  43 we notice that even if we include all the remaining numbers (in this case, there is only one), we can’t get to 100 There is no need to try the x numbers When we get to  101 we notice that we have overshot, hence no solution is possible with what we have so far We don’t need to try any of the x x numbers

8 Still exponential Even with pruning, the sum of subsets typically requires exponential time However, in some cases, pruning can save significant amounts of time Consider trying to find a subset of {23, 29, 35, 41, 43, 46, 48, 51} that sums to 100 Here, pruning can save substantial effort Sometimes, common sense can be a big help Consider trying to find a subset of {16, 20, 28, 34, 44, 48} that sums to 75

9 The End

10 Boolean satisfaction Suppose you have n boolean variables, a, b, c,..., that occur in a logical expression such as (a or c or not f) and (not b or not d or a) and... The problem is to assign true / false values to each of the boolean variables in such a way as to satisfy (make true ) the logical expression The brute-force algorithm is the same as before ( 0 is false, 1 is true, try all n binary numbers) Again, you can do significant pruning, if you think about the problem