2018-2019 AP Computer Science Quizzes

Get Number Quiz (11 Dec 2018, AP Computer Science Principles).

See: https://errless.blogspot.com/2018/12/get-number-quiz.html

Quiz 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
where & represents the bitwise AND operation, | represents the bitwise OR operation, ^ represents the bitwise XOR (exclusive OR) operation, and ~ represents the bitwise NOT operation. Let all sequences of digits represent non-negative integers. Express your binary (base 2) answers as 8-digit values, and express your hexadecimal (base 16) answers as 4-digit values; pad your answers with leading zeros as necessary.

x =
y =

  1. (x & y)2 =
  2. (x & y)16 =
  3. (x & y)10 =
  4. (x | y)2 =
  5. (x | y)16 =
  6. (x | y)10 =
  7. (x ^ y)2 =
  8. (x ^ y)16 =
  9. (x ^ y)10 =
  10. (~x)2 =
  11. (~x)16 =
  12. (~x)10 =
  13. (~y)2 =
  14. (~y)16 =
  15. (~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.

  1. If any object is not on side B, then the man assesses the situation and acts as follows; otherwise, the procedure terminates.
    1. 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.)
    2. 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.)
    3. 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.)
    4. 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.)
    5. Otherwise, if the man and the fox are on side A, then the man and the fox cross the river together.
    6. Otherwise, if the man and the chicken are on side A, then the man and the chicken cross the river together.
    7. Otherwise, if the man and the grain are on side A, then the man takes the grain across the river.
    8. 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.)
  2. Go to step 1.

Questions and Exercises

  1. Five Questions
    1. Is it theoretically possible for Procedure FCG2 to not terminate?
    2. Are any of the steps in Procedure FCG2 not precisely defined? If so, what is potentially confusing about the wording?
    3. What are the inputs to Procedure FCG2, if any?
    4. What are the outputs produced by Procedure FCG2, if any?
    5. 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?
  2. According to the definitions that Donald Knuth gives in section 1.1 of The Art of Computer Programming,
    1. Is it best to refer to the procedure shown above as an algorithm, a computational method, or a program? Explain your answer.
    2. Are none or more than one of the terms algorithm, computational method, program technically applicable, strictly according to Knuth’s definitions?
  3. What is the minimum number of times that the man will cross the river when Procedure FCG2 is performed?
  4. Compose a procedure that is similar to the one shown above but is different in two ways:
    1. 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.
    2. 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.
    Everything else about the procedure should be effectively the same as the procedure above. Try to come up with a procedure that you think will be unique compared to the procedures your classmates compose. If your procedure is unique in terms of how the man uses a die or dice to make decisions, you will receive a special reward.
  5. 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.
  1. 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.
  2. 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.