Unit 3 Final Exam (Study Guide 3)
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.
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.
Which of the following decimal (base-10) values is equivalent to the binary (base-2) value 101001?
41
From the following blocks, a code segment can be formed which will swap the values of the variables a and b. 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
The following code segment is intended to display the difference in the sums of two non-empty lists of integers, list1 and list2. 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
ASCII is a character-encoding scheme that uses a numeric value to represent each character. For example, the uppercase letter "G" is represented by the decimal (base 10) value 71. A partial list of characters and their corresponding ASCII values are shown in the table below.ASCII characters can also be represented by binary numbers. According to ASCII character encoding, which of the following letters is represented by the binary (base 2) number 1010100?
T
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.
Below is the International Morse Code, where each letter is made up of a unique combination of dots and dashes. This code is an example of what type of encoding?
Variable width
Which of the following cannot be represented by a single binary digit?
Which color is currently being shown by a traffic light
What list will be displayed when the following code segment is run?
banana, banana, apple, banana, grape, kiwi, orange
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.
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. Which of the following best describes the behavior of the program?
The program displays the number of words not equal to stopValue subtracted from the number of words equal to stopValue.
The elements of the list "months" are given below: What is the output of the following block? (Hint: think about case sensitivity.)
True
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
Refer to the following code segment: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
The following two algorithms are designed to find the number of integers on a list which have a value greater than 5.Algorithm I:Create a variable count and set this to zero. For each value on the list, check whether it is greater than 5. If it is, then add 1 to the value of count. When the end of the list is reached display the value of count.Algorithm II:Create a variable count and set this to the number of items on the list. For each value on the list, check whether it is smaller than 5. If it is, then subtract 1 from the value of count. When the end of the list is reached display the value of count.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.
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.
The program below is intended to find and display the total when all the unique numbers on the list of integers numbers are summed (e.g. if a list contains a number twice it will only be added to the total once). 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 ← 1REPEAT UNTIL (index = pos) { IF (list [index] = list [pos]) { RETURN (false) } index ← index + 1 } RETURN (true) }
Consider the following code segment which makes use of the list deck and the positive integer i: 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
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