




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















General Concepts
May combine several approaches
Recursive reapply action to subproblem(s)
Some Algorithm Strategies
Recursive Algorithm
Backtracking Algorithm – Reachability
Backtracking Algorithm – Path Finding
Divide and Conquer
Divide and Conquer – Sorting
Recursively quicksort each part of array Concatenate solutions
Recursively mergesort each half Merge two sorted arrays into single sorted array
Fibonacci Algorithm
fibonacci(1) = 1 fibonacci(n) = fibonacci(n-1) + fibonacci(n-2)
Else compute fibonacci(n-1) and fibonacci(n-2) Return their sum
Dynamic Programming – Fibonacci
Else solve fibonacci(n-1) and fibonacci(n-2) Look up value if previously computed Find their sum and store^ Else recursively compute
Since solving fibonacci(n-2) is just looking up value
Greedy Algorithm
At each step of algorithm Choose best local solution
Find minimum number of coins for 40 Greedy Algorithm fails
Greedy Algorithm – Shortest Path (A to E)
Does not yield overall (global) shortest path
A→B→E Cost^ ^6
Brute Force Algorithm
Generate and evaluate possible solutions until Satisfactory solution is found Best solution is found (if can be determined) All possible solutions found Return best solution Return failure if no satisfactory solution
Brute Force Algorithm – Shortest Path
Examines all paths in graph