CPSC 100, Spring 1997:
Answers to Quiz #7

This is the seventh and last quiz from the course Computer Science 100: Principles of Computer Science, taught by David Eck. The answers that are included here are sample answers only. There might be many other answers to a given problem that would also receive full credit. See the home page for the text, The Most Complex Machine, for more information about the course.


Question 1: Draw the picture produced by the following xTurtle program:

         Fork(6)
         turn(6 * ForkNumber)
         forward(5)
         turn(45)
         forward(5)

Answer: The Fork(6) command creates six turtles, and each of these turtles executes the remaining commands. The second line of the program tells the six turtles to turn to angles of 60, 120, 180, 240, 300, and 360 degrees. Each turtle then draws a bent line radiating out from the origin. This line consists of two segments, with an angle of 45 degrees between them. Here is the picture:

(six bent branches)


Question 2: Define the term protocol, as it relates to computer networks, and give an example of a commonly used protocol.

Answer: A protocol is a specification of how communication is to occur. For two computers to communicate, they must both be using the same protocol, so that each computer can correctly interpret the bits transmitted by the other computer. Some commonly used protocols for computer networking include IP, TCP, FTP, Telnet, and HTTP. (Since networks use "layered" protocols, a given communication can involve several different protocols. For example: FTP is used to transmit files between computers. To do this, FTP calls upon TCP, which is responsible for reliably transmitting a block of data. TCP, in turn, uses IP which knows how to route a packet of bits from one computer to another across a complicated internet. Essentially, you use FTP as a black box, FTP uses TCP as a black box, and TCP uses IP as a black box. This layering of protocols is a good example of structured complexity.)


Question 3: Define the term critical region, as it relates to programs that use parallel processing.

Answer: A critical region is a segment of a program where a process needs exclusive access to a shared variable. (In the xTurtle language, exclusive access can be implemented by using the grab statement.)


Question 4: What is the basic difference between painting and drawing programs?

Answer: In a painting program, the user creates an image by coloring pixels. The only data that the computer remembers is the color of each pixel. The computer does not know about objects in the scene, and therefore it is not possible for the user to manipulate those objects as such. In a drawing program, the computer keeps a database containing information about all the objects in the scene. The computer "renders" the scene described by this database. The objects can be manipulated by, for example, moving them, rotating them, resizing them, or changing their color.


Question 5: Explain briefly how a computer does animation.

Answer: In a computer animation, the computer renders a series of frames. Each frame is an individual image. There are small changes from one frame to the next. For example, an object might be moved or the position of a light source might change. When the frames are played back at a rate of 10 to 60 frames per second, the viewer will perceive continuous motion.


David Eck, 3 June 1997