Get Number Quiz (11 Dec 2018, AP Computer Science Principles).
See: https://errless.blogspot.com/2018/12/get-number-quiz.htmlQuiz 4 (29 Nov - 7 Dec 2018, AP Computer Science A).
Do the exercises posted at https://errless.blogspot.com/2018/11/stacks.html.
- Exercises 1-3 should be completed by the end of the class period on 30 Nov.
- Exercises 4-6 should be completed by the end of the class period on 5 Dec.
- Exercises 7-9 should be completed by the end of the class period on 7 Dec.
Quiz 3 (28 September 2018, AP Computer Science A and Principles).
Instructions
You may take this quiz multiple times. Each time you attempt the quiz, record the quiz number (Quiz 3) and the date and time that you begin and finish the quiz in your class notebook. Below the date and times, record the values of x and y generated when you click the “Random X, Y” button below. Then record your answers to each of the 15 question in your notebook. Label your answers 1-15, and record both the expression and your answer.
When you are finished taking the quiz, click the “Answers” button and grade your quiz yourself. Record the number of answers you got correct and clearly mark any answers you got wrong. If any of your answers are incorrect, try to figure out why you got the wrong answer. For example, did you not understand a concept or did you make a math error? Briefly note the reason for your wrong answers, if any, next to those answers in your notebook.
Repeat — i.e. retake the quiz with another pair of random inputs — until you are satisfied with your performance and are confident that you understand how the bitwise operators work and how to convert from base 2 to base 16 and base 10.
Problem Statement
Let x and y be a pair of pseudo-randomly generated sequences of eight bits (binary digits). Compute the base 2, base 16, and base 10 values of the expressions
- x & y
- x | y
- x ^ y
- ~x
- ~y
x =
y =
- (x & y)2 =
- (x & y)16 =
- (x & y)10 =
- (x | y)2 =
- (x | y)16 =
- (x | y)10 =
- (x ^ y)2 =
- (x ^ y)16 =
- (x ^ y)10 =
- (~x)2 =
- (~x)16 =
- (~x)10 =
- (~y)2 =
- (~y)16 =
- (~y)10 =
Quiz 2 (7 September 2018, AP Computer Science A and Principles).
The questions and exercises that comprise this quiz refer to the following procedure, which should look familiar to you. In your journal write today’s date. Below the date, write "Quiz #2". Below that, record your answers to the quiz questions and exercises. Clearly label each of your answers with the same label that appears next to the corresponding question/exercise. For extra credit, copy the question or prompt before recording your answer.
Procedure FCG2 (fox, chicken, grain puzzle, method 2). Assume the same rules, preconditions, and labels (i.e. side A and side B) as those of Algorithm FCG1.
- If any object is not on side B, then the man assesses the situation and acts as follows; otherwise, the procedure terminates.
∎
- If every object is on side A, then the man crosses the river with the chicken. (The chicken cannot be left alone with either the grain or the fox.)
- Otherwise, if the man, the fox, and the chicken are on the same side of the river, then the man flips a coin: if the result is heads, then the man and the fox cross the river together; if the result is tails, then the man and the chicken cross the river. (The fox and the chicken cannot be left alone together. The man knows this, but he’s doesn’t know much else. He’s not innovative, and inefficiency doesn’t bother him. He’s a proud union man.)
- Otherwise, if the man, the chicken, and the grain are on the same side of the river, then the man flips a coin: if the result is heads, then the man and the chicken cross the river together; if the result is tails, then the man and the grain cross the river together. (The man knows that the chicken and the grain cannot be left alone together.)
- Otherwise, if the man, the fox, and the grain are on side A, then the man flips a coin: if the result is heads, then the man and the fox cross the river together; if the result is tails, then the man and the grain cross the river together. (The man knows he needs to get every object to side B and can only take one thing with him in the boat at a time. He doesn’t care whether the fox or the grain gets there first.)
- Otherwise, if the man and the fox are on side A, then the man and the fox cross the river together.
- Otherwise, if the man and the chicken are on side A, then the man and the chicken cross the river together.
- Otherwise, if the man and the grain are on side A, then the man takes the grain across the river.
- Otherwise, if any object is on side A, then the man crosses the river alone. (The man can see that there’s still work to be done, and he knows he’d better not be caught doing nothing.)
- Go to step 1.
Questions and Exercises
- Five Questions
- Is it theoretically possible for Procedure FCG2 to not terminate?
- Are any of the steps in Procedure FCG2 not precisely defined? If so, what is potentially confusing about the wording?
- What are the inputs to Procedure FCG2, if any?
- What are the outputs produced by Procedure FCG2, if any?
- Are any of the steps in Procedure FCG2 not sufficiently basic that they could, in principle, be carried out in a finite length of time by a person?
- According to the definitions that Donald Knuth gives in section 1.1 of The Art of Computer Programming,
- Is it best to refer to the procedure shown above as an algorithm, a computational method, or a program? Explain your answer.
- Are none or more than one of the terms algorithm, computational method, program technically applicable, strictly according to Knuth’s definitions?
- What is the minimum number of times that the man will cross the river when Procedure FCG2 is performed?
- Compose a procedure that is similar to the one shown above but is different in two ways:
- Replace the statement that begins “Assume...” with a clear, concise description of the rules, preconditions, and labels that the statement refers to. Use your own words.
- Your procedure should make use one or two typical six-sided dice instead of a coin. The end result should be the same, In other words, the probability of the man taking a given object with him on a trip across the river should be the same whether the man uses a coin toss to make a decision as described above or whether he uses one or two dice as you describe in your procedure.
- Using an actual die or pair of dice, perform your procedure two times and record the results. Before executing the first step and after each step, record whether the fox, the chicken, and the grain are on side A or on side B of the river. (Remember, side A is the side that all the objects are on at the beginning of the procedure, and side B is the side that they should all be on if/when the procedure terminates.) Also record the number of times that the man has crossed the river so far. Clearly indicate what step your data is associated with.
Quiz 1 (6 September 2018, AP Computer Science A and Principles)
In your journal write today’s date. Below the date, write "Quiz #1". Below that, write the number of each question/prompt and supply your response per the instructions provided below. On this particular quiz, you may use any resources that are available to you, including consulting with your classmates. However, you must do your own work and use your own words when answering the questions.- This is a short answer question. Using your own words, clearly and concisely paraphrase the cell phone policy for Mr. Spurgeon’s computer science classes. Be as brief as possible without omitting any important details.
- This is a fill-in-the-blank question. Copy the following paragraph and supply the missing five-letter word.
Mr. Spurgeon wants to have fun and be nice, but he also has to enforce rules. He is like a traffic cop. I should not __________, because cheating is like a 15-year-old driving drunk down a one-way street in the wrong direction in a school zone when children are present at 100 miles per hour. Furthermore, if I enable someone else’s cheating by giving them a copy of my work, that is like being the business with a liquor license that supplied the alcohol to said drunk driver.