QUESTION A: Access the Blacksburg Electronic Village (BEV) Web site [www.bev.net] and answer the following questions. According to the BEV Web site (not according to something you might already know about Blacksburg!):
a. What is BEV (NOT what does BEV stand for)?
b. When was BEV's "official opening"?
c. What percentage of Blacksburg's population is estimated to be using
the Internet?
d. Who is the principal of Kipps Elementary School?
QUESTION B: Trace through the following decimal addition algorithm:
Given: m >= 1 and two positive numbers each containing m digits, a_{m-1}
a_{m-2} ... a_{0} and b_{m-1} b_{m-2} ...
b_{0}
Wanted: c_{m} c_{m-1} c_{m-2} ... c_{0},
where c_{m} c_{m-1} ... c_{0} = (a_{m-1}
a_{m-2} ... a_{0})+(b_{m-1} b_{m-2} ...
b_{0})
Algorithm:
Step 1: Set the value of carry to 0. Step 2: Set the value of i equal to the value 0. Step 3: Repeat the instructions in steps 4 through 6 until the value of i is greater than m-1.Step 4: Add the two digits a_{i} and b_{i} to the current value of carry to get c_{i}. Step 5: If c_{i} >= 10, then reset c_{i }to (c_{i}-10) and reset the value of carry to 1; otherwise, set the new value of carry to 0. Step 6: Add 1 to i, effectively moving one column to the left.Step 7: Set c_{m} to the value of carry. Step 8: Print out the final answer, c_{m }c_{m-1 }c_{m-2 ... }c_{0}. Step 9: Stop.
Using the following input values:
m = 3 a_{2} = 1 a_{1} = 4 a_{0} = 9
b_{2} = 0 b_{1} = 2 b_{0} = 9
At each step, show the values for c_{3, }c_{2, }c_{1,
}c_{0}, and carry.
This answer should be in a tabular form as shown below, with one line listed for each step that executes. Hints: Some steps may execute more than once, some steps may not execute at all. At some points during execution, it may not be possible to determine the value of some values. If this occurs, indicate that, for example, x is unknown.
Step number |
Values of variables | |||||
carry | c_{3} | c_{2} | c_{1} | c_{0} | i | |
Step1 | ||||||
QUESTION C: Based on the definition of "algorithm" given in class and in the book, is the following an algorithm? Why Not?
Step 1. Go to your bank and withdraw $10. Step 2. Give the money to your Computer Science professor. Step 3. Go to step 1.
QUESTION D: Using only the sequential operations, write an algorithm that inputs four numbers corresponding to scores received on three semester tests and a final examination. Your algorithm should compute and display the average of all four tests, weighing the final examination twice as heavily as a regular test.
QUESTION E: Modify the test-averaging algorithm of the above question so that it inputs 15 test scores rather than 4. There are 14 regular tests and a final examination, which again counts twice as much as a regular test. Use a loop to input and sum the scores.
QUESTION F: We wish to create an algorithm that prints out whether a current student is in elementary (1st - 5th), middle (6th - 8th), or high school (9th - 12th). Does the following algorithm correctly do this? Briefly explain why or why not.
Step 1. If (grade <= 5) then print "this student is in elementary school" Step 2. If (grade <= 8) then print "this student is in middle school" Step 3. Else (grade <= 12) then print "this student is in high school"
Once you have completed these questions on paper, you may go to the quiz index at any time. However you should check the time period when the quiz is available. Note that you may check the index of quizzes at any time in WebCT, but once you start into the quiz itself the clock starts.
Go to CS1104 Homepage
Last updated 00/12/12
© J.A.N. Lee, 2000.