APCSP 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The program makes use of a procedure named IsFirstOccurence. Which of the following definitions of this procedure would cause the program to function as intended?

PROCEDURE IsFirstOccurence(list, pos) { index ← 1 REPEAT UNTIL (index = pos) { IF (list [index] = list [pos]) { RETURN (false) } index ← index + 1 } RETURN (true)

Procedures are abstract:

all of the above

Assuming number must be larger than 1, what must go in the <MISSING CODE> section to make this procedure work as expected?

count = 2

Which of the following initial values for x, y and z can be used to show that the code segment does not work as intended?

x = 3, y = 2, z = 1

Which of the following scenarios will likely result in an overflow error?

A program which stores positive integers using 4 bits attempts to add the (decimal) integers 7 and 9.

What is string1 concatenated with string 2 when: string1 <-- "Tik" string2 <--"Tok"

"TikTok"

What is returned by a call to taxman ("food", 1.00)?

06

The following scratch program is run:

10

Sam's password is known to be formed of 3 decimal digits (0-9) in a given order. Karren and Larry are attempting to determine Sam's password by testing all possible combinations. If they are only able to try 10 combinations every day, how many days would it take to try all the possible combinations?

100

How many more bits are available if you go from a 32-bit computer to a 64-bit machine?

2 ^32 more ( 2 to the power 32)

Which of the following decimal values, when converted to binary (ignore leading zeros) have exactly 3 zeros in them? Select two answers.

20 50

ASCII is a common format for the representation of characters in writing code. How many characters can be represented in the standard ASCII encoding?

27

ASCII is a common format for the representation of characters in writing code. How many characters can be represented in the standard ASCII encoding?

2^7

The following steps can be used to encode a string of text using Base64 encoding: 1. Convert the ASCII characters to their corresponding decimal value2. Convert the decimal values to their 8-bit equivalents3. Join all of the bits together to form one continuous string4. Split the combined string into groups of 6 bits5. From left to right, convert each group of 6 bits to their corresponding decimal values6. Convert those decimal values back to the corresponding Base64 values If I started with the three ASCII characters "CSP", how many Base64 values will I be left with at the end?

4

A large company uses 10-bit binary numbers to identify its employee records. It plans to change this system to use 12-bit binary numbers instead. Which of the following statements best describes the effects of this change?

4 times the number of individual records can potentially be stored.

What value does the following code segment display?

53

How many distinct values can be represented with 6 bits of data?

64

What is the value of z at the end of this procedure if x was 20 and y was 2 when the procedure was called?

84

What can be determined from the following program flow? Intro ( ) Rules ( ) Play ( ) Score ( ) DISPLAY (HighScore ( ) )

A game is played by calling different procedures.

The procedure check is supposed to display a statement correctly comparing the size of the two provided numbers, value1 and value2. Which of the following changes to the code would be the best choice to make the procedure work as intended?

Add another IF / ELSE block, nested in the ELSE section

Which of the following statements correctly demonstrates that the two algorithms are NOT equivalent?

Algorithm I will correctly display the number of integers greater than 5 on the list [4, 10, 5, 1], but Algorithm II will not.

What could a binary number represent?

All of the above

Which of the following statements about 32-bit binary values is NOT true?

All real numbers within a finite interval can be expressed by a 32-bit integer representation.

The code segment below uses the procedure IsPartOf (list, item), which returns true if item appears in list and returns false otherwise. The list newList is initially empty. FOR EACH item IN oldList { IF (NOT IsPartOf (newList, item)) { APPEND (newList, item) } } Which of the following best describes the contents of newList after the code segment is executed?

All unique elements in oldList NOT including any repeats of elements.

How do parameters and arguments differ?

Arguments are sent to procedure where they are then used as parameters.

What is the number system used by computers?

Base 2 (binary)

Which of the following does NOT describe a real benefit from using abstraction in programming?

By storing a set of integers using a list variable, the actual values of these integers can be kept hidden from someone reading the code, increasing security.

The procedure below is intended to return true if a particular city name (cityName) appears more than once in a list of cities (cityList), and false if it does not appear, or only appears once in the list.

Calling the procedure CityRepeat (["New York", "Los Angeles" "New York", "Chicago"], "Boston") shows that the procedure does not work as intended in this case.

Students were asked to order a list of the seven days of a week, without a specification as to the rules of the ordering. Which of the following ordered lists may be considered correctly ordered?

I, II and III

Which are most abstract: high-level or low-level programming languages?

High-level

Remember that "state space" refers to the space of all potential possibilities. Which dichotomous questions below will successfully narrow down the entire state space of "flipping a coin and rolling a normal six-sided die" to 1 or fewer possible outcomes regardless of the answers given?

Did the coin land on heads?Is the value on the die odd?Is the value on the die more than 3?Does the value on the die equal 1, 2, 5 or 6?

Consider the following procedure. PROCEDURE find (target, list) { i ← 1 FOR EACH item IN list { IF (item = target) { DISPLAY (i) } i ← i + 1 } }

Displays the positions of all occurrences of target in list

Digital noise is relevant or meaningful data that has found its way into otherwise meaningful code.

False

Which statement below are true about fixed and variable width encoding? Select two Answers.

Fixed width encoding are typically longer than variable width encodings. Variable width encoding must use extra bits to specify where character start/end.

In a certain country, a person must be at least 16 years old to drive a car and must be at least 18 years old to vote. The variable age represents the age of a person as an integer. Which of the following expression evaluates to true if the person is old enough to drive but not old enough to vote, and evaluates to false otherwise? I. ( age ≥ 16 ) AND ( age ≤ 18 ) II. ( age ≥ 16 ) AND (NOT ( age ≥ 18 ) ) III. ( age < 18) AND (NOT (age < 16 ) )

II and III only

Daija is creating a budget, and evaluating his purchases over the last month. Consider the following code segment which attempts to find the sum of all purchases made in the last month, stored in purchaseList. n ← 1 sum ← 0 REPEAT UNTIL () { sum ← sum + purchaseList[n] n ← n + 1 } What code can replace missing code to assign the total of all values in purchaseList to sum? I. n = LENGTH (purchaseList) II. n ≥ LENGTH (purchaseList) III. n > LENGTH (purchaseList)

III only

Which of the following gives a correct, ordered set of instructions which will create a code segment swapping the initial values of a and b?

IV, I, II

Which of the following changes will reduce the number of operations performed by the program without making it incorrect?

Interchanging line 11 and line 12

The list mine is initialized with the values -- green, red, blue, purple, yellow, black -- and the list yours is initialized with the values -- green, red, black, blue. What will be displayed after the following code segment runs?

None of the messages listed are displayed: Partway through, an error message is produced and the program terminates.

Which type of loop runs a set number of times?

Repeat n Times

Algorithms can be written with a combination of what three statements?

Sequence/ Selection/ Iteration

Which of the following best describes abstraction?

Simplifying complexity to make the concept more general

A program is used to print name tags for guests at an event. Unfortunately for each guest it prints the last name before the first name when the opposite is desired. The procedure for printing the name tags uses the variables FN for the first name and LN for last name. Which of the following code segments, inserted in the correct place in the procedure will cause the program to print the name tags in the desired way?

Temp ← LN LN ← FN FN ← Temp

--

The average of grades above 79.

What will the following code produce? X<-- 5 Y<--X X<--Y+ 5 Repeat Until (X > Y) { DISPLAY ("Hello World!")

The code inside the Repeat UNTIL loop never executes.

A city engineer is tasked with studying vehicular traffic patterns throughout a large metropolitan area. He designs a number of small, remote devices that can be installed along streets throughout the city to sense and record the hundreds of cars that pass through each of the city's five busiest intersections during a 24-hour period. Every time a car trips the sensor in a device, it increments an internal, 5-bit counter that stores the number of cars that have passed through the intersection since the counter was last reset. Every 24 hours, each device transmits the 5-bit value stored in its counter back to a central server that collects the daily data from all of the devices throughout the city. After transmitting, the counter in each device is reset back to 0. Fortunately, the engineer's supervisor points out a flaw in the device's design and orders that the engineer modify the design specifications for this device before building and installing the sensors. Which of the following is most likely the design flaw in this scenario?

The counter is not capable of counting hundreds of cars without exceeding the limit of the five bits of storage.

Which of the following best describes what this fragment of code does when the current player achieves a score which is higher than the current high score?

The current player's name is inserted in the first position in the list scoreboard, the name of the previous high scorer is deleted and all other names remain in the same position in the list.

Which of the following is not true about digitizing physical media?

The digital version is always equally as good as the physical one in terms of quality.

Which of the following can be represented by a single binary digit?

The direction of travel for an elevator

Assuming that the list months contains exactly 12 elements, what would happen when the script below is run?

The list months will remain unchanged.

As movies and music have moved into the digital world, the legal protections that relate to them have had to continually evolve. Which of the following best describes how the legal landscape regarding the digital movies and music has changed?

The music and movie industries have chosen to protect their copyrights by filing lawsuits against people who share digital files without permission.

Given a list of integers, sequence, and an integer, value, which of the following best describes what the code segment does?

The number of items in sequence that are less than value is displayed.

If our list called List is populated as [0, 1, 2, 3, 4], what happens if our code tries to access List [5] per the rules of the AP Computer Science Principles Reference Guide?

The output will be 4

Consider the following program, which is intended to display the number of items on a list which are not equal to an item called stopValue.

The program displays the number of words not equal to stopValue subtracted from the number of words equal to stopValue.

What would be the result of running the program below? list ← [ 1, 2, 3 ] APPEND ( list, 5 ) INSERT ( list, 4, 4 ) REMOVE ( list, 5 ) DISPLAY ( list )

The program would display the list [1, 2, 3, 4].

Which of the following can be stored in a bit?

The result of a number MOD 2 A Boolean Variables

What will be the effect on words, a non-empty list of strings, when the following Scratch program is run?

The strings in words will be sorted into alphabetical order.

Don wishes to swap the values of the variables x and y in his program. He adds a line of code which sets the value of x to the value of y and then a line of code which sets the value of y to the value of x. What is the effect of Don's code?

The values of both x and y will be set to the original value of y.

Consider the following algorithm. Subtract 1 from the current value of Y and store the answer as the new value of YSet the value of X to the current value of Y+1Set the value of X to the current value of YRepeat steps 1 to 3 until X = 10 Which of the following best describes the behavior of this algorithm based on the starting values of the variables X and Y?

There are many possible starting values for X and Y which will cause the algorithm to eventually terminate, and many possible starting values for X and Y which will cause the algorithm to run indefinitely

How can programmers avoid duplicating code?

Through the use of iteration

Which of the following could be displayed when this segment of code is executed, assuming that the block will sort the parameter list in alphabetical order from A to Z, and the user responds to each input?

Tim Tim Tim

Why is analyzing data with computers important?

To identify patterns that humans cannot see

Lists are widely used in programming, however, lists are not necessary for all programming tasks. In which of the following situations would you be least likely to need to use a list in a program?

Tracking the last song that played in a game, so that people playing the game don't hear the same song twice in a row.

A linear sequence of characters, words, or other data is a string.

True

Baudot code is an example of fixed-width encoding.

True

What is the output of the following block? (Hint: think about case sensitivity.)

True

A binary encoding system that can represent much more of the world's text than ASCII is called _____________.

Unicode

Below is the International Morse Code, where each letter is made up of a unique combination of dots and dashes.

Variable Width

When is a compound condition using the logical operator AND true?

When both conditions are true

Which of the following cannot be represented by a single binary digit?

Which color is currently being shown by a traffic light

Which of the following questions cannot be easily answered using a binary set of answers?

Which is the best song new song from last year?

Which of the following lists will cause the program to give an incorrect output?

[-1,1,4,0]

What list will be displayed when the following code segment is run?

banana, banana, apple, banana, grape, kiwi, orange

Assuming that the list newAnimals is initially empty, what would this list contain after the following code segment is run?

eagle, duck, dog

What will be the contents of finalList after running this program?

finalList, will contain all the words found in list1 and list2 in alphabetical order, but it may contain repeated words.

A teacher uses the following program to adjust student grades on an assignment by adding 5 points to each student's original grade. However, if adding 5 points to a student's original grade causes the grade to exceed 100 points, the student will receive the maximum possible score of 100 points. The students' original grades are stored in the list gradeList, which is indexed from 1 to n.

gradeList [i] ← gradeList[i] + 5 IF (gradeList [i] > 100) { gradeList [i] ← 100 } gradeList [i] ← min (gradeList[i] + 5, 100)

Which of the following list assignments will demonstrate that the procedure does NOT work as intended? Select two answers.

list ← [ ] list ← [-5, -3, -10, -8, -1]

While running this code segment, the user enters the following values when prompted: pizza yes bread no. What is stored in the list called grocery after the block of code is executed?

milk, bread, pizza, eggs, cheese

At the end of the code segment below, what will be said for 2 seconds?

mixxixxixxi

In order to program a robot to move around within a two-dimensional space, a programmer considers four different designs for defining the robot's behavior. Which of the following sets of procedures would be the best design in terms of the readability, efficiency, and flexibility of the resulting program?

move(dir, dist): Moves the robot dist spaces in the dir direction, where dist is a number and dir is NORTH, SOUTH, EAST or WEST

Sometimes we care about the order of a list, and need to reorder the items according to a condition (alphabetical, numerical, etc). An algorithm finds the minimum value in the list and swaps it with the value in the first position, then repeats these steps for the remainder of the list, swapping with the second position, then the third position and so forth. What type of sorting is this?

selection

A gaming software company gave their new customers a survey, asking them to rate various aspects of a new product on a scale of 1 to 5. The integer values of their answers were stored in a list feedback. Which code segments would assign the mean average value of the items on the list to the variable average? Select two.

sum ← 0 FOR EACH item IN feedback { sum ← sum + item } average ← sum / LENGTH(feedback) sum ← 0 item ← 1 REPEAT LENGTH(feedback) times { sum ← sum + feedback[item] item ← item + 1 } average ← sum / LENGTH(feedback)

There is a base 6 number system that uses symbols instead of numerals to represent different values. Below is the symbol that represents each numeral. ⤲ = 0↺ = 1➣ = 2⬳ = 3⤴ = 4⇶ = 5 Which of the following numbers written using this base 6 number system is equivalent to the base 10 number 147?

⤴ ⤲ ⬳


Set pelajaran terkait

Final Business Economics Final Exam Review

View Set

Chapter 3: Corporate Social Responsibility & Citizenship

View Set

NASM Corrective exercise specialist

View Set

Chapter 32 Quiz: Environmental Emergencies

View Set

Kapitel 3 - marked, udbud og efterspørgsel

View Set