(25) Algorithm Strategies

# (25) Algorithm Strategies - Problem type CMSC 132:...

This preview shows pages 1–3. Sign up to view the full content.

1 CMSC 132: Object-Oriented Programming II Algorithm Strategies Department of Computer Science University of Maryland, College Park 2 Problem type Satisfying Find any satisfactory solution Example- find a path from A to F Optimization Find the best solution (vs. cost metric) Example- find the shortest path from A to E A C E D 3 8 5 1 7 2 B 6 4 F 3 Some algorithm strategies Recursive algorithms Backtracking algorithms Divide and conquer algorithms Dynamic programming algorithms Greedy algorithms Brute force algorithms Branch and bound algorithms Heuristic algorithms 4 Recursive algorithms This approach is based on reapplying an algorithm to its subproblems You are already experts in recursion

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
5 Backtracking algorithms This approach is based on depth-first recursive search Approach: 1. Test whether a solution has been found; if so, return it 2. Otherwise for each choice that can be made: a) Recurse on that choice b) If the recursion returns a solution, return it 3. If no choices remain, return failure 6 Backtracking algorithm– reachability Find a path in a graph from start to destination 1. Start with currentNode = start 2. If currentNode has an edge to destination , return the path 3. Otherwise select a neighbor node x of currentNode
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/16/2011 for the course CMSC 132 taught by Professor Padua-perez during the Fall '08 term at Maryland.

### Page1 / 5

(25) Algorithm Strategies - Problem type CMSC 132:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online