Algorithm Efficiency Homework
Quick practice with Algorithm Efficiency
1️⃣ Decision vs Optimization
A. Is there a path from your house to school?
B. What is the shortest path from your house to school?
C. Can all classes fit into a weekly schedule without overlap?
D. Minimize total travel time for deliveries to 10 cities.
Type A or B for each question below
A.
B.
C.
D.
2️⃣ Algorithm Efficiency Table
Input Size (n) | Algorithm X Steps | Algorithm Y Steps | Algorithm Z Steps |
---|---|---|---|
1 | 3 | 2 | 1 |
2 | 6 | 4 | 2 |
3 | 9 | 8 | 6 |
4 | 12 | 16 | 24 |
5 | 15 | 32 | 120 |
3️⃣ Algorithm A (grows by 3ⁿ)
Input Size (n) | Steps |
---|---|
1 | 3 |
2 | |
3 | |
4 | |
5 |
4️⃣ Counting Steps
Compares every pair of items in a list of size n.
1) Steps for n=4:
2) Efficiency type:
3) Reasonable for very large lists?
5️⃣ Heuristic Scenario
Scenario: A city wants to design bus routes covering all neighborhoods. There are hundreds of possible routes, and finding the perfect shortest set is too complex.
1) Explain one heuristic approach the city could use:
2) Why might this heuristic not give the optimal solution?
6️⃣ Algorithm B
Input Size (n) | Steps |
---|---|
1 | 2 |
2 | 4 |
3 | 8 |
4 | ? |
5 | ? |
Efficiency type:
Reasonable for large n?
7️⃣ TSP Heuristic
Scenario: A city wants to design bus routes covering all neighborhoods. There are hundreds of possible routes, and finding the perfect shortest set is too complex.
Select the approach the city could use:
8️⃣ Efficiency Ranking
n | Algorithm P | Algorithm Q | Algorithm R |
---|---|---|---|
1 | 1 | 1 | 2 |
2 | 2 | 4 | 4 |
3 | 3 | 9 | 8 |
4 | 4 | 16 | 16 |
5 | 5 | 25 | 32 |