Download presentation
Presentation is loading. Please wait.
Published byBrittney Booth Modified over 8 years ago
1
Algorithms Classroom Activities Richard Anderson University of Washington July 3, 20081IUCEE: Algorithm Activities
2
What does it mean for an algorithm to be efficient? July 3, 20082IUCEE: 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 July 3, 20083IUCEE: Algorithm Activities
4
Find a topological order for the following graph E F D A C B K J G H I L July 3, 20084IUCEE: Algorithm Activities
5
How many processors are needed for this example? July 3, 20085IUCEE: Algorithm Activities
6
Prove that you cannot schedule this set of intervals with two processors July 3, 20086IUCEE: Algorithm Activities
7
Who was Dijkstra? What were his major contributions? July 3, 20087IUCEE: Algorithm Activities
8
Solve by unrolling T(n) = n + 5T(n/2) July 3, 20088IUCEE: Algorithm Activities
9
Classify the following recurrences (Increasing, Decreasing, Balanced) T(n) = n + 5T(n/8) T(n) = n + 9T(n/8) T(n) = n 2 + 4T(n/2) T(n) = n 3 + 7T(n/2) T(n) = n 1/2 + 3T(n/4) July 3, 20089IUCEE: Algorithm Activities
10
Integer Arithmetic 9715480283945084383094856701043643845790217965702956767 + 1242431098234099057329075097179898430928779579277597977 2095067093034680994318596846868779409766717133476767930 X 5920175091777634709677679342929097012308956679993010921 Runtime for standard algorithm to add two n digit numbers: Runtime for standard algorithm to multiply two n digit numbers: July 3, 200810IUCEE: Algorithm Activities
11
Subset Sum Problem Let w 1,…,w n = {6, 8, 9, 11, 13, 16, 18, 24} Find a subset that has as large a sum as possible, without exceeding 50 July 3, 200811IUCEE: Algorithm Activities
12
Knapsack Grid 4 3 2 1 00000000000000000 Weights {2, 4, 7, 10} Values: {3, 5, 9, 16} Opt[ j, K] = max(Opt[ j – 1, K], Opt[ j – 1, K – w j ] + v j ) July 3, 200812IUCEE: Algorithm Activities
13
Determine the LCS of the following strings BARTHOLEMEWSIMPSON KRUSTYTHECLOWN July 3, 200813IUCEE: 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. July 3, 200814IUCEE: Algorithm Activities
15
Find two augmenting paths st 2/5 0/1 3/4 3/3 2/4 1/3 3/3 2/2 3/4 1/3 3/3 2/2 3/3 1/3 2/2 1/3 July 3, 200815IUCEE: Algorithm Activities
16
Find a minimum value cut s t 6 6 10 7 3 5 36 2 4 5 8 5 4 8 July 3, 200816IUCEE: Algorithm Activities
17
Enumerate all finite s,t cuts and show their capacities -212 1 s t 2 2 1 1 2 July 3, 200817IUCEE: Algorithm Activities
18
Baseball elimination Can the Dinosaurs win the league? Remaining games: –AB, AC, AD, AD, AD, BC, BC, BC, BD, CD WL Ants42 Bees42 Cockroaches33 Dinosaurs15 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 July 3, 200818IUCEE: Algorithm Activities
19
Circuit SAT AND OR AND OR ANDNOTOR NOT x1x1 x2x2 x3x3 x4x4 x5x5 AND NOT AND OR NOT AND OR AND Find a satisfying assignment July 3, 200819IUCEE: 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 3 2 6 7 4 5 1 3 2 6 7 4 5 Construct the complement July 3, 200820IUCEE: Algorithm Activities
21
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) 1 2 4 2 3 5 4 7 7 1 Find the minimum cost tour July 3, 200821IUCEE: Algorithm Activities
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.