CSP Jan 3. CB Questions

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

A sorted list of numbers contains 500 elements. Which of the following is closest to the maximum number of list elements that will be examined when performing a binary search for a value in the list? A 10 B 50 C 250 D 500

A. 10

A computer program uses 3 bits to represent integers. When the program adds the decimal (base 10) numbers 5 and 3, the result is 0. Which of the following is the best explanation for the result? A An overflow error occurred. B A round-off error occurred. C The result was affected by lossy data compression. D The result was approximated by a floating-point representation.

A. An overflow error occurred

Some programming languages use constants, which are variables that are initialized at the beginning of a program and never changed. Which of the following are good uses for a constant? I. To represent the mathematical value π (pi) as 3.14II. ii. To represent the current score in a gameIII. iii. To represent a known value such as the number of days in a week A I and II only B I and III only C II and III only D I, II, and III

B. I and III only

DineOutHelper is a mobile application that people can use to select a restaurant for a group meal. Each user creates a profile with a unique username and a list of food allergies or dietary restrictions. Each user can then build a contact list of other users of the app. A user who is organizing a meal with a group selects all the members of the group from the user's contact list. The application then recommends one or more nearby restaurants based on whether the restaurant can accommodate all of the group members' allergies and dietary restrictions. Suppose that Alejandra is using DineOutHelper to organize a meal with Brandon and Cynthia. Which of the following data is not provided by Alejandra but is necessary for DineOutHelper to recommend a restaurant for the group? I. Brandon's contact list II. Information about which restaurants Brandon and Cynthia have visited in the past III. Information about which food allergies and dietary restrictions can be accommodated at different restaurants near Alejandra A II only B III only C II and III only D I, II, and III

B. III only

Which of the following can be represented by a single binary digit? Select two answers. A The position of the minute hand of a clock B The remainder when dividing a whole number by 2 C The value of a Boolean variable D The volume of a car radio

B. The remainder when dividing a whole number by 2 C. The value of a Boolean variable

Suppose that a list of numbers contains values [-4, -1, 1, 5, 2, 10, 10, 15, 30]. Which of the following best explains why a binary search should NOT be used to search for an item in this list? A The list contains both positive and negative elements. B The elements of the list are not sorted. C The list contains an odd number of elements. D The list contains duplicate elements.

B. the elements of the list are not sorted

A video-streaming Web site uses 32-bit integers to count the number of times each video has been played. In anticipation of some videos being played more times than can be represented with 32 bits, the Web site is planning to change to 64-bit integers for the counter. Which of the following best describes the result of using 64-bit integers instead of 32-bit integers? A 2 times as many values can be represented. B 32 times as many values can be represented. C 2^32 times as many values can be represented. D 32^2 times as many values can be represented.

C. 2^32 times as many values can be represented

A certain programming language uses 4-bit binary sequences to represent nonnegative integers. For example, the binary sequence 0101 represents the corresponding decimal value 5. Using this programming language, a programmer attempts to add the decimal values 14 and 15 and assign the sum to the variable total. Which of the following best describes the result of this operation? A The correct sum of 29 will be assigned to the variable total. B An overflow error will occur because 4 bits is not large enough to represent either of the values 14 or 15. C An overflow error will occur because 4 bits is not large enough to represent 29, the sum of 14 and 15. D A round-off error will occur because the decimal values 14 and 15 are represented as approximations due to the fixed number of bits used to represent numbers.

C. An overflow error will occur because 4 bits is not large enough to represent 29, the sum of 14 and 15.

A video game character can face toward one of four directions: north, south, east, and west. Each direction is stored in memory as a sequence of four bits. A new version of the game is created in which the character can face toward one of eight directions, adding northwest, northeast, southwest, and southeast to the original four possibilities. Which of the following statements is true about how the eight directions must be stored in memory? A Four bits are not enough to store the eight directions. Five bits are needed for the new version of the game. B Four bits are not enough to store the eight directions. Eight bits are needed for the new version of the game. C Four bits are not enough to store the eight directions. Sixteen bits are needed for the new version of the game. D Four bits are enough to store the eight directions.

D. Four bits are enough to store the eight directions

For which of the following lists can a binary search be used to search for an item in the list? ["blue", "green", "jade", "mauve", "pink"] [5, 5, 5, 5, 6, 7, 8, 8, 8] [10, 5, 3, 2, -4, -8, -9, -12] A I only B III only C I and III only D I, II, and III

D. I, II, and III


Kaugnay na mga set ng pag-aaral

N1240 Case Study: Pharmacology Medical Surgical Drugs

View Set

BIOL 1322 Nutrition & Diet Therapy Chapter 6 Smart Book

View Set

The Great Gatsby Chapter 1-5 Questions

View Set

chapter 1: themes and streams of American popular music _

View Set