1 / 21

Algorithms Classroom Activities

Algorithms Classroom Activities. Richard Anderson University of Washington. What does it mean for an algorithm to be efficient?. Polynomial vs. Exponential Complexity. Suppose you have an algorithm which takes n! steps on a problem of size n

lloydk
Download Presentation

Algorithms Classroom Activities

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. Algorithms Classroom Activities Richard Anderson University of Washington IUCEE: Algorithm Activities

  2. What does it mean for an algorithm to be efficient? IUCEE: Algorithm Activities

  3. Polynomial vs. Exponential Complexity • Suppose you have an algorithm which takes n! steps on a problem of size n • If the algorithm takes one second for a problem of size 10, estimate the run time for the following problems sizes: 12 14 16 18 20 10: 1 second 12: 2 minutes 14: 6 hours 16: 2 months 18: 50 years 20: 20K years IUCEE: Algorithm Activities

  4. Find a topological order for the following graph H E I A D G J C F K B L IUCEE: Algorithm Activities

  5. How many processors are needed for this example? IUCEE: Algorithm Activities

  6. Prove that you cannot schedule this set of intervals with two processors IUCEE: Algorithm Activities

  7. Who was Dijkstra? • What were his major contributions? IUCEE: Algorithm Activities

  8. Solve by unrollingT(n) = n + 5T(n/2) Answer: nlog(5/2) IUCEE: Algorithm Activities

  9. Classify the following recurrences(Increasing, Decreasing, Balanced) • T(n) = n + 5T(n/8) • T(n) = n + 9T(n/8) • T(n) = n2 + 4T(n/2) • T(n) = n3 + 7T(n/2) • T(n) = n1/2 + 3T(n/4) IUCEE: Algorithm Activities

  10. Integer Arithmetic 9715480283945084383094856701043643845790217965702956767 + 1242431098234099057329075097179898430928779579277597977 Runtime for standard algorithm to add two n digit numbers: 2095067093034680994318596846868779409766717133476767930 X 5920175091777634709677679342929097012308956679993010921 Runtime for standard algorithm to multiply two n digit numbers: IUCEE: Algorithm Activities

  11. Subset Sum Problem • Let w1,…,wn = {6, 8, 9, 11, 13, 16, 18, 24} • Find a subset that has as large a sum as possible, without exceeding 50 IUCEE: Algorithm Activities

  12. Knapsack Grid Opt[ j, K] = max(Opt[ j – 1, K], Opt[ j – 1, K – wj] + vj) Weights {2, 4, 7, 10} Values: {3, 5, 9, 16} IUCEE: Algorithm Activities

  13. Determine the LCS of the following strings BARTHOLEMEWSIMPSON KRUSTYTHECLOWN IUCEE: Algorithm Activities

  14. How good is this algorithm? • Is it feasible to compute the LCS of two strings of length 100,000 on a standard desktop PC? Why or why not. IUCEE: Algorithm Activities

  15. Find two augmenting paths 2/5 2/2 0/1 2/4 3/4 3/4 3/3 3/3 1/3 1/3 s t 3/3 3/3 2/2 1/3 3/3 1/3 2/2 1/3 IUCEE: Algorithm Activities

  16. Find a minimum value cut 6 6 5 8 10 3 6 2 t s 7 4 5 3 8 5 4 IUCEE: Algorithm Activities

  17. Enumerate all finite s,t cuts and show their capacities s 2 2 -2 1 2 -2 1 1 2 1 t IUCEE: Algorithm Activities

  18. Baseball elimination • Can the Dinosaurs win the league? • Remaining games: • AB, AC, AD, AD, AD, BC, BC, BC, BD, CD A team wins the league if it has strictly more wins than any other team at the end of the season A team ties for first place if no team has more wins, and there is some other team with the same number of wins IUCEE: Algorithm Activities

  19. Circuit SAT Satisfying assignment x1 = T, x2 = F, x3 = F x4 = T, x5 = T AND OR OR Find a satisfying assignment AND AND AND AND NOT OR NOT OR AND OR AND NOT AND NOT OR NOT AND x3 x4 x5 x1 x2 IUCEE: Algorithm Activities

  20. Complement of a Graph • Defn: G’=(V,E’) is the complement of G=(V,E) if (u,v) is in E’ iff (u,v) is not in E 1 2 1 2 3 5 3 5 4 4 6 6 7 7 Construct the complement IUCEE: Algorithm Activities

  21. Minimum cost tour highlighted Traveling Salesman Problem • Given a complete graph with edge weights, determine the shortest tour that includes all of the vertices (visit each vertex exactly once, and get back to the starting point) 3 7 7 2 2 5 4 1 1 4 IUCEE: Algorithm Activities Find the minimum cost tour

More Related