CS99 Fall 2000 Review Questions for Prelim 1 1. How does statement (a) differ from statement (b)? (a) > C:=5; (b) > C=5; Answer: Statement (a) assigns the value 5 to the variable C. Statement (b) merely states the equation C=5. In other words, no assignments occur during statement (b). 2. Does the following statement assign the value 1 to sin? > sin:=1; Answer: No, sin is a protected name. 3. Draw an expression tree for a*b+c*d. Answer: [Can't draw the answer here. We'll go over this in the review session.] 4. What is the surface type of the previous equation? Answer: + 5. Assume that you have made the assignment t:=7 in your Maple session. What are two ways to unassign the value of t, without closing down your Maple session? Answer: a. t:='t'; b. restart; 6. What is the output that results from the following Maple input? > 6-7-1; Answer: -2. Note that this evaluates from left to right, and that it makes a difference in this example whether you evaluate from left to right or from right to left. 7. What is Maple? Answer: Maple is a computer algebra system, used primarily for symbolic analysis. 8. What is Maple's response to the following input? > t:=7 Answer: "Warning, premature end of input". Note that there's no semicolon or colon. 9. How do you plot f(x)=x+2, for -1 <= x <= 1? Give the plot the title "Test Plot". Answer: > x:='x'; > plot(x+2, x=-1..1, title="Test Plot"); Note that we needed to unassign the value of x! 10. Define a list called List consisting of the numbers 1, 3, 3, and 5. Answer: > List:=[1,3,3,5]; 11. Once List is formed as above, how do you extract the 3rd element? Answer: > List[3]; 12. Define a set called Set consisting of the numbers 1, 3, 3, and 5. Answer: There are two possible answers here. You could have typed in the elements literally, like: > Set:={1,3,3,5}; Or, you could have noted that sets are unordered, so the above set is actually equal to: > Set:={1,3,5}; NOTE: Read up on section 4.6 if problems 10-12 are confusing to you. 13. Read over your first homework, the shoelace tying algorithm. We will go over an algorithm tomorrow during the review session. Please ask at that time if you have any questions about writing an algorithm.