Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 10: Algorithm Design Techniques

Similar presentations


Presentation on theme: "Chapter 10: Algorithm Design Techniques"— Presentation transcript:

1 Chapter 10: Algorithm Design Techniques
Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Chapter 10: Algorithm Design Techniques Backtracking Lydia Sinapova, Simpson College

2 Backtracking How to solve a problem by search Generate and Test
What is Backtracking Example

3 The Idea Problem solving: search in a space of possible states.
Initial state Target state2 Target state1

4 Generate and Test Method
Take a state Generate next states by applying relevant rules (not all rules are applicable for a given state!) Test to see if the goal state is reached. If yes - stop   If no - add the generated states into a stack/queue (do not add if the state has already been generated) and repeat the procedure. To get the solution: Record the paths

5 Search Methods Breadth-first vs depth-first search
Exhaustive search (brute force) vs informative (constraint-based, heuristic) search Backtracking

6 Backtracking rejecting the currently reached state as a dead-end state, going back to some previous level in the state-space tree/graph proceeding with the exploration of other paths toward the target state Backtracking occurs in depth-first search

7 Example Replace the letters with distinct digits such that the addition is correct Decide on: State representation Operators Constraints Initial state Target state   LOAN + LOAN LOAN DEBT


Download ppt "Chapter 10: Algorithm Design Techniques"

Similar presentations


Ads by Google