Homework 9
Total: 60 Points
Write Up (20 pts)
-Concise description of what the program does/does not do. (10 pts)
-Concise description of the bottlenecks encountered. ( 4 pts)
-Concise discussion of how the program handled these bottlenecks ( 3 pts)
-Concise discussion of the approximations used in the program. ( 3 pts)
Program (40 pts)
-does not run (10/40 pts)
-passes test cases 1,2. BFS works (20/40 pts)
-passes test cases 1 thru 4. BFS, MM work (30/40 pts)
-passes test cases 1 thru 6. BFS, MM, approximations work (40/40 pts)
Test Cases
Case1. n = 7 Minimum is 3 flips
Seq: 5 6 1 2 3 4 7
Case2. n = 7 Minimum is 7 flips
Seq: 1 5 2 6 3 7 4
Case 3. n = 15 Minimum is 3 flips
Seq: 13 14 15 12 11 1 2 3 4 5 6 7 8 9 10
Case4. n = 15 Minimum is at least 15 flips
Seq: 1 9 2 10 3 11 4 12 5 13 6 14 7 15 8
Case5. n = 101 Minimum is 3 flips
Seq: 60 61 … 74 75 59 58 … 52 51 1 2 … 49 50 76 77 … 100 101
Case6. n = 101 Minimum is at least n flips
n = 2m + 1 = 101 then m = 50
Seq in terms of m:
1 m+2 2 m+3 3 m+4 4 ….. m+m m 2m+1 m+1
Definitions:
MM – memory management
BFS – Breadth First Search
61 … 74 Consecutive ints from 61 up to 74
58 … 52 Consecutive ints from 58 down to 52
77 … 100 Consecutive ints from 77 up to 100