1 / 9

Exploring Backtracking Methods: Knapsack & Tic-Tac-Toe Solutions

Discover the intricacies of backtracking methods in solving problems like the knapsack conundrum and Tic-Tac-Toe strategies. Learn about subset and permutation trees, bounding functions, and the role of backtracking in optimizing solutions. Delve into practical examples like finding optimal moves in games and solving maze puzzles. Gain insights into the depth-first search approach and how it aids in navigating potential solutions efficiently.

Download Presentation

Exploring Backtracking Methods: Knapsack & Tic-Tac-Toe Solutions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Backtracking 4-12-2002

  2. Opening Discussion • What did we talk about last class? • Do you have any questions about the assignments?

  3. Backtracking • This method is basically a standard recursive depth-first decent over the possible solutions to a problem. In the worst case it examines all the solutions to a problem and from that it picks the best one as the solution to the optimization. • The way we often visualize this is as a tree of possible solutions that we are recursing through. The leaves denote solutions.

  4. Knapsack Problems • Consider a thief who is robbing a store. In the store are a number of items of weight, wi, and value, vi. There are two forms of this problem. In the 0/1 knapsack problem each item must be taken as a whole. Alternately the thief could take fractional amounts of each item. In both cases he wants maximum value for a weight W. • The first is what we are interested in because the second can easily be solved with a greedy algorithm. This can also be solved using Dynamic Programming.

  5. Subset Tree • The solution tree when we are asked to decide on an optimal subset of a certain set is called a subset tree. This is what the 0/1 knapsack problem requires. • These are typically exponential in size because each element of the original set is either in the subset or not so the tree branches twice at every level.

  6. Bounding Functions • The thing that save us is that we can rule out certain paths without traversing all children. Strategies that kill nodes without looking at their children are called bounding functions. • For the 0/1 knapsack we can kill paths that have more weight than we can carry. What other ways can we kill paths?

  7. Tic-Tac-Toe • Your book gives the example of a program to find the best moves to make in a Tic-Tac-Toe game. • Here the first play can be one of 9 moves. The next player gets 8 options and so on. The total number of possible games is 9!. • In the book the objective is to find paths that help one player win. This way the tree can be pruned using a “minimax” strategy.

  8. Permutation Tree • When the problem asks for a permutation on a set the solution tree is called a permutation tree and it typically scales factorially. • This is what we get for the Tic-Tac-Toe problem. It also happens to be the type of solution tree we get for a famous problem called the travelling salesman problem (TSP).

  9. Minute Essay • Another interesting problem to solve using backtracking is trying to get out of a maze. Describe in English how this might work. Feel free to write pseudocode if you want. • In theory you should turn in assignment #5 on Monday.

More Related