Chapter 1 Answers Exam Preparation Exercises 1. a: v, b: i, c: viii, d: iii, e: iv, f: vii, g: vi, h: ii. 2. Analysis and specification, general solution (algorithm), verify. 3. Concrete solution (program), test. 4. The analysis and specification step within the problem-solving phase. 5. The steps never end. Changing the last step to say, "Repeat from first step until graduation," converts the sequence into an algorithm that eventually ends, assuming the person will graduate from school some day. We can make sure that this loop ends by specifying a condition that will definitely occur. For example, "Repeat from first step until last day of classes." 6. a: v, b: ii, c: iv. d: i, e: vi, f: iii. 7. The program can be compiled on different computer systems without modification. 8. The control unit directs the actions of the other components in the computer to execute program instruction in the proper order. 9. False. The editor is software rather than hardware. 10. False. Peripheral devices are external to the CPU and its main memory. 11. Yes. If the software license restricts use to a single computer or a single user, then this is a case of piracy, even though you split the cost. 12. a: ii, b: v, c: iii, d: vii, e: i, f: vi, g: iv. Programming Warm-Up Exercises 1. Branches: Steps n1, n2, and n3. There are two loops: steps p, q. and r; and steps t and u. Steps a, c, and e are references to subalgorithms defined elsewhere. 2. Follow separate algorithm for filling glass with water and placing on counter If right handed, pick up toothpaste tube in left hand and unscrew cap by turning counter-clockwise place toothpaste cap on counter transfer toothpaste tube to right hand and pick up toothbrush in left hand, holding it by its handle place open end of toothpaste tube against tips of brush bristles and squeeze toothpaste tube just enough to create a 0.5 inch long extrusion of toothpaste on the brush. pull toothpaste tube away from brush and place tube on counter transfer toothbrush to right hand, holding it by its handle open mouth and insert brush, placing toothpaste-covered bristles against one tooth scrub tooth with brush by moving brush up and down ten times reposition brush to an unscrubbed tooth repeat previous two steps until all teeth have been brushed spit toothpaste into sink put toothbrush in sink pick up glass in right hand fill mouth with water from glass swish water in mouth for five seconds spit water from mouth into sink repeat previous three steps three times Otherwise (if left-handed) pick up toothpaste tube in right hand and unscrew cap by turning counter-clockwise place toothpaste cap on counter transfer toothpaste tube to left hand and pick up toothbrush in right hand, holding it by its handle place open end of toothpaste tube against tips of brush bristles and squeeze toothpaste tube just enough to create a 0.5 inch long extrusion of toothpaste on the brush. pull toothpaste tube away from brush and place tube on counter transfer toothbrush to left hand, holding it by its handle open mouth and insert brush, placing toothpaste-covered bristles against one tooth scrub tooth with brush by moving brush up and down ten times reposition brush to an unscrubbed tooth repeat previous two steps until all teeth have been brushed spit toothpaste into sink put toothbrush in sink pick up glass in right hand fill mouth with water from glass swish water in mouth for five seconds spit water from mouth into sink repeat previous three steps three times Place glass on counter Follow separate algorithm for cleaning up after brushing teeth 3. The test for right or left handedness is a branch. In each branch there are two loops, one that iterates until all teeth are brushed, and the other iterates rinsing four times. The first and last step refer to separately defined subalgorithms. 4. Change step u to: u. Repeat step t nine times.