This file contains questions asked by students along with the answers provided. (The identity of the students will not be included) New Q&A will be added at the top of this file as they arrive -- it's a stack. ----------------------------------------------------- Question 4 PrettyPut as it appeared in assignment 3 printed the 'left' subtree first and 'right' subtree second. I thought this appropriate because if you read the page from top to bottom you get the left to right information. However, many people complained that if you rotated the resulting page so that the root was at the top and the branches came down (as you would draw the tree on the board) then the left and right were switched. This is why PrettyPut as it appears in assignment 4 prints the 'right' subtree first and the 'left' second. This is how it appears in sample.out. If you are finding nPointingAtMe to get negative values, then you are subtracting 1 from it more times than you are adding one to it. ----------------------------------------------------- 3 Hint: March 28 It was said that the nPointingAtMe variable of a node must count the number of pointers pointing at the node. There are difficulties with this. - Suppose that the address of a node is passes to a subroutine (function or procedure). Then the routine's local variable is pointing at the node, but the count nPointingAtMe did not increase. - Suppose a subroutine has a local variable that is pointing at a node. When that routine returns that local variable will be gone. Hence it will no longer be pointing at the node. However, there is no mechanism for changing the count nPointingAtMe when this happens. In some ways, these two problems cancel each other. One does not need to include in the count pointers that are local variables to a routine. Be aware of which local variables are and are not included in the count, so that you can maintain the count. ----------------------------------------------------- Question 2: March 24 Let me clarify: The recursion for the Finalize operation must be moved to FreeMe. Suppose for example that node u is pointed to by many pointers and that node v is pointed to by node u, but by no other pointers. Think about what should happen when FreeMe is called for u. After FreeMe has been called for u enough times so that the counter nPointAtMe goes to zero the node must freed. What then happens to node v? ----------------------------------------------------- Question 1: March 21 Independent of how long the Strike goes on, unless otherwise notified, assume the assignment is due on Wednesday, April 9, 1997, 10:30 am. The sample.in/out files will likely change. Like the last assignment. If you understand the material, the assignment will be easy. If you do not understand the material you will fail the exam. Remember the assignment is worth only 7.5% while the exam is worth 50%. Have fun.