c262f97t3 - CSc 262 Test 3 Wednesday 12 November 1997...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSc 262 Test 3 Wednesday 12 November 1997 Closed book, closed notes. Suggested answers available after test. 1. (40 pts) Below is a Pascal program to list the moves in solving the Towers of Hanoi problem. Certain statements in the program have comment numbers (appearing inside (* *) ) along with the address where the code generated by the compiler for the statement begins. Assume that the stack for the activation records starts at address 8000, that every entry on the stack takes one memory location on the stack, and that the stack pointer increases as items are pushed on the stack. Show the status of the stack and state the value of EP and SP when the call HANOI(3,2,1) is about to execute after the following calling sequence in the execution of the program: --(*6)-->HANOI(5,1,3)--(*4*)-->HANOI(4,2,3)--(*2*)-->HANOI(3,2,1) where the comment numbers indicate the statement where the call was made. Whenever possible, you should enter the appropriate number in the stack entry: the address of a statement, the value of a variable, etc. PROGRAM ONE; PROCEDURE HANOI(DISKS,FROMPOST,TOPOST:INTEGER); BEGIN IF DISKS>0 (*1 1982*) THEN BEGIN
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern