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

Info iconThis 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 HANOI(DISKS-1,FROMPOST,6-FROMPOST-TOPOST);
Background image of page 1

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

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

This note was uploaded on 03/09/2008 for the course CSC 262 taught by Professor Varies during the Spring '08 term at Lehigh University .

Page1 / 3

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online