Algorithms Classroom Activities - PowerPoint PPT Presentation

About This Presentation
Title:

Algorithms Classroom Activities

Description:

Algorithms Classroom Activities. Richard Anderson. University of ... Activities ... IUCEE: Algorithm Activities. Enumerate all finite s,t cuts and show ... – PowerPoint PPT presentation

Number of Views:213
Avg rating:3.0/5.0
Slides: 22
Provided by: rich484
Category:

less

Transcript and Presenter's Notes

Title: Algorithms Classroom Activities


1
Algorithms Classroom Activities
  • Richard Anderson
  • University of Washington

2
What does it mean for an algorithm to be
efficient?

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
4
Find a topological order for the following graph
H
E
I
A
D
G
J
C
F
K
B
L
5
How many processors are needed for this example?
6
Prove that you cannot schedule this set of
intervals with two processors
7
Who was Dijkstra?
  • What were his major contributions?

8
Solve by unrollingT(n) n 5T(n/2)
Answer nlog(5/2)
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)

10
Integer Arithmetic
971548028394508438309485670104364384579021796
5702956767 12424310982340990573290750971798984
30928779579277597977
Runtime for standard algorithm to add two n digit
numbers
209506709303468099431859684686877940976671713
3476767930 X 59201750917776347096776793429290970
12308956679993010921
Runtime for standard algorithm to multiply two n
digit numbers
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

12
Knapsack Grid
Opt j, K max(Opt j 1, K, Opt j 1, K
wj vj)
4
3
2
1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Weights 2, 4, 7, 10 Values 3, 5, 9, 16
13
Determine the LCS of the following strings
BARTHOLEMEWSIMPSON KRUSTYTHECLOWN
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.

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
16
Find a minimum value cut
6
6
5
8
10
3
6
t
2
s
7
4
5
3
8
5
4
17
Enumerate all finite s,t cuts and show their
capacities
s
2
2
-2
1
2
-2
1
1
2
1
t
18
Baseball elimination
  • Can the Dinosaurs win the league?
  • Remaining games
  • AB, AC, AD, AD, AD, BC, BC, BC, BD, CD

W L
Ants 4 2
Bees 4 2
Cockroaches 3 3
Dinosaurs 1 5
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
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
AND
OR
NOT
AND
NOT
OR
NOT
AND
x3
x4
x5
x1
x2
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
21
Traveling Salesman Problem
Minimum cost tour highlighted
  • 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
Find the minimum cost tour
Write a Comment
User Comments (0)
About PowerShow.com