APCSP Unit 4

Ace your homework & exams now with Quizwiz!

Evaluate the following expression. Type your answer into the Textbox. 3^3 mod 5

2

Suppose your PRNG uses the following formula: Xi+1 = Xi * 2 + 1 And suppose that X1 is 10. What are the next three numbers that the formula would generate? Type your answers into the text box, separating the numbers by a single comma.

21, 43, 87

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of goats and sheep throughout the text. Consider the programmer's goal of changing all occurrences of "goats" to "sheep" and all occurrences of "sheep" to "goats." e programmer will use the fact that the word "foxes" does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish the programmer's goal? (A) First, change all occurrences of "goats" to "sheep." en, change all occurrences of "sheep" to "goats." (B) First, change all occurrences of "goats" to "sheep." en, change all occurrences of "sheep" to "goats." Last, change all occurrences of "foxes" to "sheep." (C) First, change all occurrences of "goats" to "foxes." en, change all occurrences of "sheep" to "goats." Last, change all occurrences of "foxes" to "sheep." (D) First, change all occurrences of "goats" to "foxes." en, change all occurrences of "foxes" to "sheep." Last, change all occurrences of "sheep" to "goats."

C

Assuming that forward tells the Android to move forward by 10 pixels and turn tells it to turn right by 90 degrees, what shape would be drawn by this algorithm? forward forward turn forward turn forward forward turn forward turn A. A square B. A right angle C. A rectangle D. A circle

C

Biologists o en attach tracking collars to wild animals. For each animal, the following geolocation data is collected at frequent intervals. § e time § e date § e location of the animal Which of the following questions about a particular animal could NOT be answered using only the data collected from the tracking collars? (A) Approximately how many miles did the animal travel in one week? (B) Does the animal travel in groups with other tracked animals? (C) Do the movement patterns of the animal vary according to the weather? (D) In what geographic locations does the animal typically travel?

C

Under which of the following conditions is it most bene cial to use a heuristic approach to solve a problem? (A) When the problem can be solved in a reasonable time and an approximate solution is acceptable (B) When the problem can be solved in a reasonable time and an exact solution is needed (C) When the problem cannot be solved in a reasonable time and an approximate solution is acceptable (D) When the problem cannot be solved in a reasonable time and an exact solution is needed

C

What event causes the Mole to move to a new random location? A. When the score changes. B. When the user tilts the phone. C. When the Clock Timer ticks. D. When the Reset button is pressed.

C

What's the Algorithm? Generation 0 of the 4-bit computer comes pre-loaded with a program that adds 1 and 2 and outputs their sum, 3. The value 1 in decimal is stored in location 1000. And the value 2 is stored in location 1001. Which of the following pseudocode algorithms correctly describes that program's machine language algorithm? A. Load the value at 1000 into the Accumulator Add the value in 1001 to the Accumulator Print the value in location 1010 Stop B. Load the value at 1000 into the Accumulator Add the value in 1000 to the Accumulator Store the Accumulator at location 1010 Print the value in location 1010 Stop C. Load the value at 1000 into the Accumulator Add the value in 1001 to the Accumulator Store the Accumulator at location 1010 Print the value in location 1010 Stop D. Load the value at 1000 into the Accumulator Add the value in 1001 to the Accumulator Store the Accumulator at location 1010 Stop

C

Which of the following statements describes a limitation of using a computer simulation to model a real-world object or system? (A) Computer simulations can only be built after the real-world object or system has been created. (B) Computer simulations only run on very powerful computers that are not available to the general public. (C) Computer simulations usually make some simplifying assumptions about the real-world object or system being modeled. (D) It is difficult to change input parameters or conditions when using computer simulations.

C

Suppose your PRNG uses the following formula: Xi+1 = Xi * 2 + 1 And suppose that X1 is 12. What value will X2 have?

25

Suppose your PRNG uses the following formula: Xi+1 = (Xi * 2 + 1) mod 13 What would the next number be if the current number is 10?

8

Suppose your PRNG uses the following formula: Xi+1 = (Xi * 2 + 1) mod 13 What would the next five numbers be if the current number is 10? Separate the numbers in your sequence by commas.

8, 4, 9, 6, 0

Our 4-bit computer uses 8-bit bytes to represent its data. An 8-bit byte can store values ranging from 0 to 255 -- i.e., 00000000 to 11111111. What do you suppose would happen if you added 1 to 11111111? To help answer this question, you might want to use the 4-bit simulator to write a little machine language program to see what happens. By default, the 4-bit computer adds the values in locations 1000 and 1001 and prints the sum. So here is how you would set up the machine to add 11111111 and 00000001: Put the value 11111111 (decimal 255) in memory location 1000. Put the value 00000001 (decimal 1) in memory location 1001. Run the program and observe the output. What decimal value do you get when you add binary 1 to binary 11111111? A. 0 B. 255 C. 256 D. No value. The machine would crash.

A

Which of the following are true statements about digital certi cates in Web browsers? I. Digital certi cates are used to verify the ownership of encrypted keys used in secured communication. II. Digital certi cates are used to verify that the connection to a Web site is fault tolerant. (A) I only (B) II only (C) I and II (D) Neither I nor II

A

If the variables onTime and absent both have the value false, what is displayed as a result of running the code segment? (A) Is anyone there? (B) Better late than never. (C) Hello. Is anyone there? (D) Hello. Better late than never.

B

True or False: You can drag and drop the ImageSprite Component from Animation tab directly onto the screen? A. True B. False

B

In the 4-bit computer we can find several occurrences of the 4-bit string, 0011. What does this string of bits represent? Choose all answers that apply. A. The decimal value 3. B. The machine instruction for ADDing a number to the accumulator. C. A memory location in the computer's RAM. D. The decimal value 17.

A, B, C

Which of the following would be examples of random events? A. Choosing a ball from a jar of red and black balls. B. Rolling a 12-sided die. C. Counting by 2s up to 20. D. Flipping a coin that has 3 sides. E. Dealing a hand of poker.

A, B, D, E

True or False? An algorithm is a precise sequence of statements that must be expressed in a computer language. A. True B. False

B

An o ce building has two oors. A computer program is used to control an elevator that travels between the two oors. Physical sensors are used to set the following Boolean variables. e elevator moves when the door is closed and the elevator is called to the oor that it is not currently on. Which of the following Boolean expressions can be used in a selection statement to cause the elevator to move? (A) (onFloor1 AND callTo2) AND (onFloor2 AND callTo1) (B) (onFloor1 AND callTo2) OR (onFloor2 AND callTo1) (C) (onFloor1 OR callTo2) AND (onFloor2 OR callTo1) (D) (onFloor1 OR callTo2) OR (onFloor2 OR callTo1)

B

For the following block what possible values would be assigned to X? set global x to random integer from 1 to 3. A. 1 or 3 B. 1, 2, or 3 C. 1 or 2 D. 1

B

Which of the following algorithms require both selection and iteration? Select two answers. (A) An algorithm that, given two integers, displays the greater of the two integers (B) An algorithm that, given a list of integers, displays the number of even integers in the list (C) An algorithm that, given a list of integers, displays only the negative integers in the list (D) An algorithm that, given a list of integers, displays the sum of the integers in the list

B, C

ere are 32 students standing in a classroom. Two di erent algorithms are given for nding the average height of the students. Algorithm A Step 1: Step 2: Step 3: Step 4: Step 5: All students stand. A randomly selected student writes his or her height on a card and is seated. A randomly selected standing student adds his or her height to the value on the card, records the new value on the card, and is seated. e previous value on the card is erased. Repeat step 3 until no students remain standing. e sum on the card is divided by 32. e result is given to the teacher. Algorithm B Step 1: Step 2: Step 3: Step 4: Step 5: All students stand. Each student is given a card. Each student writes his or her height on the card. Standing students form random pairs at the same time. Each pair adds the numbers written on their cards and writes the result on one student's card; the other student is seated. e previous value on the card is erased. Repeat step 3 until one student remains standing. e sum on the last student's card is divided by 32. e result is given to the teacher. Which of the following statements is true? (A) Algorithm A always calculates the correct average, but Algorithm B does not. (B) Algorithm B always calculates the correct average, but Algorithm A does not. (C) Both Algorithm A and Algorithm B always calculate the correct average. (D) Neither Algorithm A nor Algorithm B calculates the correct average.

C

An ImageSprite component can only be inserted into what other component? A. Label B. Button C. Ball D. Canvas

D

The program segment below is intended to move a robot in a grid to a gray square. e program segment uses the procedure GoalReached, which evaluates to true if the robot is in the gray square and evaluates to false otherwise. e robot in each grid is represented as a triangle and is initially facing le . e robot can move into a white or gray square but cannot move into a black region. REPEAT UNTIL (GoalReached ()) { IF (CAN_MOVE (forward)) { MOVE_FORWARD () }IF (CAN_MOVE (right)) { ROTATE_RIGHT () }IF (CAN_MOVE (left)) { ROTATE_LEFT () } }For which of the following grids does the program NOT correctly move the robot to the gray square? (images)

D

What value would give the MoleTimer's TimerInterval property to have the Mole jump every 2 seconds? A. 2 B. 20 C. 200 D. 2000

D

What is the name of the computer language that uses a turtle to implement drawing algorithms? Type your answer into the textbox (spelling counts).

Logo

For the following block what value would be assigned to Label1? Type your answer into the text box. (Spelling counts. Don't use quotes.).

heads


Related study sets

English 11 Final Exam Literature Review

View Set

Chapter 12: Parts of Speech (Verbs + Adverbs + Prepositions + Conjunctions)

View Set

Living with Art: Christianity and the Formation of Europe

View Set

Olds' Ch. 17: Pregestational Problems

View Set

"All of the Following Except" Questions

View Set

Chapter 10 Quality Management and Six Sigma

View Set