Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Structures Lab Algorithm Animation.

Similar presentations


Presentation on theme: "Data Structures Lab Algorithm Animation."— Presentation transcript:

1 Data Structures Lab Algorithm Animation

2 Algorithm Categories Brute Force Greedy Heuristic Divide & Conquer
Dynamic Programming Back-Tracking Genetic

3 Brute Force Straightforward, obvious approach to solve a problem, usually involves looking at every single data point. Useful for solving small size problems, but not for large n. Typical brute force approach will give optimal solution for small problems but never end for large problems. ExamplesL Linear Search Traveling Salesman Problem (non-optimized)

4 Greedy Algorithms Take what you can get now strategy (so often involves nearest neighbor type approaches, or largest first or other types of easy to do steps). Does not always generate the optimal solution. At each step, the choice is the local optimal. Examples: Coins exchange Huffman Codes (compression algorithm)

5 Heuristic Algorithms Following a rule of thumb, usually based on domain knowledge and some kind of insight Examples: Choosing the pivot in quicksort, can be done well, if you know the data set and you have a good heuristic for finding a decent middle value Certain TSP solutions (like go around the outside and spiral in) MinMax algorithm to find a strategy in trees of possible game moves by a player and an opponent. Look at both min and max moves at each level.

6 Divide & Conquer Involves splitting the data at each step, and recursively solving. Typically, split all the way down and solve as you recurse back up. Example: Binary Search

7 P and NP Problems P stands for polynomial, refers to a class of problems that can be solved in polynomial time (n, n2, n3, etc.) NP stands for nondeterministic polynomial time, and refers to a class of problems where it is uncertain (unlikely even?) that a polynomial time solution exists. So, if a problem has a known solution that is exponential (kn), it is considered NP, because it is unknown if there is a more efficient solution to that problem.

8 P and NP and how they relate to Big O:
NP solutions P solutions

9 The P vs. NP Question If the solution to a problem is easy to check for correctness, is it easy to solve? P problems are considered easy to solve because they can be computed in polynomial time ( n, n2, n3, etc.) NP problems are those where it is easy to check whether a given solution is correct, but where we don’t know if there is a way to find a solution in polynomial time. (There may be, but we don’t know). CS people want to know if P == NP (i.e. are all problems solvable in polynomial time?)

10 Instructions Using the map-based, weighted graph on the following slide to animate how a particular algorithm works. To do this: Create multiple duplicates of the slide (the map is on a master slide) On each slide, change the nodes by animation, highlighting, etc. The purpose is to demonstrate visually, with the graph as your example, how your assigned algorithm work

11 Graph Algorithms To Choose From:
Breadth First Traversal Depth First Traversal Prim’s Algorithm (minimum spanning tree) Dykstra’s shortest path NB: each pair at each table should choose a different algorithm Spend 5-10 minutes looking up the algorithm to understand how it is supposed to work Spend the rest of the time creating the animation Make sure both partners are involved in the task

12

13

14

15

16

17

18

19 Algorithm Characteristics
Is the algorithm you just animated: Greedy? Heuristic? Divide & Conquer? Brute Force? P or NP?


Download ppt "Data Structures Lab Algorithm Animation."

Similar presentations


Ads by Google