Difference between revisions of "CSC231 Final Exam 2015"
(Created page with "<onlydft> <font color="purple">This exam is due on Dec 19, at '''noon'''. This exam is given under the rules of the ''honor code''. You have access to all your notes, to boo...") |
|||
Line 1: | Line 1: | ||
<onlydft> | <onlydft> | ||
− | <font color="purple">This exam is due on Dec | + | <br /> |
+ | <bluebox> | ||
+ | <font color="purple">This exam is due on Dec 22nd, at '''4:00 p.m.'''.</font> | ||
+ | <br /> | ||
+ | This exam is given under the rules of the ''honor code''. You have access to all your notes, to books, and to the Web. You cannot, however, discuss the details of the exam with anybody other than your instructor. Questions regarding the exam can only be asked in class, or using Piazza. Do not post code on Piazza. Do not suggest or imply possible solutions in your posts on Piazza. | ||
+ | </bluebox> | ||
− | + | =Problem #1= | |
− | |||
− | + | ==Part 1 == | |
− | |||
− | ==Part 1 | ||
You are done with your exams, and enjoying the free time before you leave the college to go around the quiet campus, and, just for fun, you stop by the campus center. After getting a nice cup of hot chocolate, you climb the steps to the second floor, and see two of your friends, both computer science majors, engaged in a heated discussion in one of the small conference rooms. You enter the room and ask them what all the fuss is about. | You are done with your exams, and enjoying the free time before you leave the college to go around the quiet campus, and, just for fun, you stop by the campus center. After getting a nice cup of hot chocolate, you climb the steps to the second floor, and see two of your friends, both computer science majors, engaged in a heated discussion in one of the small conference rooms. You enter the room and ask them what all the fuss is about. | ||
"Oh, it's this computer program," says Jane, one of your friends. We don't agree on its limits. "Maxim thinks it will run out of memory before it will ever finish, while I think we will run out of time before it finishes!" | "Oh, it's this computer program," says Jane, one of your friends. We don't agree on its limits. "Maxim thinks it will run out of memory before it will ever finish, while I think we will run out of time before it finishes!" | ||
− | (Note from DT: "running out of time" here means something that will take much much longer than we are willing to wait for. Running out of time in | + | (Note from DT: "running out of time" here means something that will take much much longer than we are willing to wait for. Running out of time in our case means an execution time of several centuries.) |
"What do you mean?" you ask. | "What do you mean?" you ask. | ||
Line 24: | Line 26: | ||
"Here. That's what we did in class the other day," says Jane, and she hands you a piece of paper with the C code for the '''moveDisk''' function: | "Here. That's what we did in class the other day," says Jane, and she hands you a piece of paper with the C code for the '''moveDisk''' function: | ||
− | + | <br /> | |
− | < | + | ::<source lang="java"> |
main() { | main() { | ||
moveDisk( 64, 'A', 'B', 'C' ); | moveDisk( 64, 'A', 'B', 'C' ); | ||
Line 39: | Line 41: | ||
} | } | ||
} | } | ||
− | </ | + | </source> |
− | + | <br /> | |
(A python version of this code is available [[CSC231 hanoi.py | here]].) | (A python version of this code is available [[CSC231 hanoi.py | here]].) | ||
− | + | <br /> | |
You take the code and sit for a while, scribbling some notes on the sheet... A few minutes later you get up and announce "Of course! ..." | You take the code and sit for a while, scribbling some notes on the sheet... A few minutes later you get up and announce "Of course! ..." | ||