Computer science practice
For which of the following strings is it NOT possible to use byte pair encoding to shorten the string's length?
"LEVEL_UP"
The code segment below is intended to display all multiples of 5 between the values start and end, inclusive. For example, if start has the value 3 5 and end has the value 5 0, the code segment should display the values 3 5, 4 0, 4 5, and 5 0. Assume that start and end are multiples of 5 and that start is less than end.
((End-start)/5) + 1
A computer program uses 4 bits to represent nonnegative integers. Which of the following statements describe a possible result when the program uses this number representation? I. The operation 4 plus 8 will result in an overflow error. II. The operation 7 plus 10 will result in an overflow error. III. The operation 12 plus 3 will result in an overflow error.
2 only
Internet protocol version 4 (IPv4) represents each IP address as a 32-bit binary number. Internet protocol version 6 (IPv6) represents each IP address as a 128-bit binary number. Which of the following best describes the result of using 128-bit addresses instead of 32-bit addresses?
2^96 as many addresses are available.
Consider the following program, which uses the variables start, end, and current. What is displayed as a result of executing the program?
3 4
The researchers noticed that the total number of registered users appears to be increasing at about a constant rate. If this pattern continues, which of the following best approximates the total number of registered users, in millions, in year 12 (two years after the last entry in the table) ?
31.2
A text-editing application uses binary sequences to represent each of 200 different characters. What is the minimum number of bits needed to assign a unique bit sequence to each of the possible characters?
8
The diagram below shows a circuit composed of three logic gates. Each gate takes two inputs and produces a single output. For which of the following input values will the circuit have an output of false ?
A A = true, B = false, C = false, D = false
The grid below contains a robot represented as a triangle, initially facing up. The robot can move into a white or gray square but cannot move into a black region. The figure shows a grid of squares with 5 columns and 4 rows. The square in the fourth row and first column contains an upward-facing triangle, representing a robot. The first row contains all white squares. The second row contains, left to right, white, black, black, black, white. The third row contains, left to right, white, black, gray, white, white. The fourth row contains, left to right, white, black, black, black, white. The code segment below uses the procedure One word, Goal Reached, which evaluates to true if the robot is in the gray square and evaluates to falseotherwise. The program consists of 4 lines. Begin program Line 1: REPEAT UNTIL, open parenthesis, one word Goal Reached, open parenthesis, close parenthesis, close parenthesis Line 2: open brace Line 3: MISSING CODE Line 4: close brace End program. Which of the following replacements for missing code can be used to move the robot to the gray square?
A IF (CAN_MOVE(right)) { ROTATE_RIGHT () } MOVE_FORWARD ()
An application program interface (API) provides a procedure Max, which returns the greater of its two integer arguments. A programmer would like to find the greatest of three integer values a, b, and c. Which of the following expressions will produce the desired result in every case?
A Max (Max(a, b), c)
A flowchart is a way to visually represent an algorithm. The flowchart below is used by an apartment rental Web site to set the variable include to true for apartments that meet certain criteria. Which of the following statements is equivalent to the algorithm in the flowchart?
A, include floor > 10 or bedrooms = 3
A library of e-books contains metadata for each book. The metadata are intended to help a search feature find books that users are interested in. Which of the following is LEAST likely to be contained in the metadata of each e-book?
An archive containing previous versions of the e-book
A student is creating a procedure to determine whether the weather for a particular month was considered very hot. The procedure takes as input a list containing daily high temperatures for a particular month. The procedure is intended to return true if the daily high temperature was at least 90 degrees for a majority of days in the month and return false otherwise. Which of the following can be used to replace missing code so that the procedure works as intended?
B Counter > 0.5 * total
While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction Win, left arrow, true somewhere in the code. Where could Win, left arrow, true be inserted so that the code segment works as intended?
B Between line 9 and line 10
A program contains the following procedures for string manipulation. Which of the following expressions can be used to generate the string Open quotation, Happy, close quotation?
B Concat (Substring ("Harp, 1, 2"), Substring ("Puppy", 3, 3))
A programmer is writing a procedure to calculate a student's final grade in the course using the score replacement policy described. The student's exam scores are stored in the variables One word, midterm Exam and One word, final Exam. The procedure Max, open parenthesis, a comma b returns the larger of a and b. Which of the following could be used in the procedure to calculate a student's total points earned in the course and store the result in the variable One word, adjusted Total ?
B adjustedTotal <— Max (midtermExam, finalExam) + finalExam
The two code segments below are each intended to display the average of the numbers in the list One word, num List. Assume that One word, num List contains more than one value. Which of the following best describes the two code segments?
Both code segments display the correct average, but code segment I requires more arithmetic operations than code segment II.
The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the bottom right square of the grid and facing toward the top of the grid. The following programs are each intended to move the robot to the gray square. Program II uses the procedure One word, Goal Reached, which returns true if the robot is in the gray square and returns false otherwise. Which of the following statements is true?
Both program I and program II correctly move the robot to the gray square.
Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in the string more than once and replaces each instance of that pair with a corresponding character that does not appear in the string. The algorithm saves a list containing the mapping of character pairs to their corresponding replacement characters. For example, the string Open quotation, THIS, underscore, IS, underscore, THE, underscore, BEST, underscore, WISH, close quotation can be encoded as Open quotation, percent, hash, underscore, hash, underscore, percent E, underscore, BEST, underscore, W, hash, H, close quotation by replacing all instances of Open quotation, T H, close quotation with Open quotation, percent, close quotationand replacing all instances of Open quotation, I S, close quotation with Open quotation, hash, close quotation. Which of the following statements about byte pair encoding is true?
Byte pair encoding is an example of a lossless transformation because an encoded string can be restored to its original version.
A NAND gate is a type of logic gate that produces an output of false only when both of its two inputs are true. Otherwise, the gate produces an output of true. Which of the following Boolean expressions correctly models a NAND gate with inputs P and Q ?
C NOT (P AND Q)
A snack bar has a frequent customer program in which every 10th purchase is free. Customers are enrolled in the program when they make their first purchase. A programmer is writing a program to implement the frequent customer program. In one code segment, cost is set to 0for every 10th purchase by a given customer. The programmer will use the procedure One word, Get Count, open parenthesis, one word, customer I D, close parenthesis , which returns the total number of purchases a customer has made since enrolling in the frequent customer program, including his or her first purchase. Which of the following code segments will set cost to 0 for every 10th purchase a customer makes after enrolling in the frequent customer program?
Count <— GetCount (customerID) IF (count MOD 10 = 0) { Cost <— 0 }
Grades in a computer science course are based on total points earned on a midterm exam and a final exam. The teacher provides a way for students to improve their course grades if they receive high scores on the final exam: if a student's final exam score is greater than the student's midterm exam score, the final exam score replaces the midterm exam score in the calculation of total points. The table below shows two students' scores on the midterm and final exams and the calculated total points each student earns. Khalil does better on the midterm exam than on the final exam, so his original midterm and final exam scores are added to compute his total points. Josefina does better on the final exam than on the midterm exam, so her final exam score replaces her midterm exam score in the total points calculation. hich of the following could be determined from the data? I. The average total points earned per student II. The average increase in total points per student as a result of the score replacement policy III. The proportion of students who improved their total points as a result of the score replacement policy
D I, II, and III
A programmer is developing a word game. The programmer wants to create an algorithm that will take a list of words and return a list containing the first letter of all words that are palindromes (words that read the same backward or forward). The returned list should be in alphabetical order. Executing which of the following sequences of steps will enable the algorithm to work as intended? I. First shorten, then keep palindromes, then sort II. First keep palindromes, then shorten, then sort III. First sort, then keep palindromes, then shorten
D II and III
A smartphone stores the following data for each photo that is taken using the phone. The file name of the photo The date and time the photo was taken The geographic location where the photo was taken Assume that all of the photos that have been taken on the phone are accessible. Which of the following can be determined using the photo data described above? I. The number of photos that were taken at a particular geographic location II. The number of photos that were taken in the last year III. The name of the person who took the most recent photo
I and II only
The procedure below searches for the value target in list. It returns true if target is found and returns false otherwise. Which of the following are true statements about the procedure? I. It implements a binary search. II. It implements a linear search. III. It only works as intended when list is sorted.
II only
Which of the following best describes one of the benefits of using an iterative and incremental process of program development?
It helps programmers identify errors as components are added to a working program.
Participants in a survey were asked how many hours per day they spend reading, how many hours per day they spend using a smartphone, and whether or not they would be interested in a smartphone application that lets users share book reviews. The data from the survey are represented in the graph below. Each × represents a survey participant who said he or she was interested in the application, and each o represents a participant who said he or she was not interested. Which of the following hypotheses is most consistent with the data in the graph?
Participants who read more were generally more likely to say they are interested in the application.
Consider the two programs below. Which of the following best compares the values displayed by programs A and B?
Program A and program B display the same number of values, but the values differ.
Which of the following can be used to replace missing code so that the code segment works as intended?
Second <— temp
Which of the following hypotheses is most consistent with the data in the table?
The mobile app release led to users tending to write shorter messages.
A computer program performs the operation 2 divided by 3 and represents the result as the value 0 point 6 6 6 6 6 6 7. Which of the following best explains this result?
The precision of the result is limited due to the constraints of using a floating-point representation.
A student wrote the procedure below, which is intended to ask whether a user wants to keep playing a game. The procedure does not work as intended. Which of the following best describes the result of running the procedure?
The procedure returns false no matter what the input value is.
Which of the following describes the result of executing the program?
The program displays the sum of the odd integers from 1 to 19.
A programmer is creating an algorithm to set the value of One word, ticket Price based on the information in the table. The programmer uses the integer variable age for the age of the moviegoer. The Boolean variable One word, is 3 D is true when the movie is 3-D and false otherwise. Which of the following code segments correctly sets the value of One word, ticket Price ?
This code segment initially sets One word, ticket Price to 12, and then changes the price to 9 only for children and senior
A media librarian at a movie studio is planning to save digital video files for archival purposes. The movie studio would like to be able to access full-quality videos if they are needed for future projects. Which of the following actions is LEAST likely to support the studio's goal?
Using lossy compression software to reduce the size requirements of the data being stored
Which of the following code segments can be used to draw the figure?
XPos <— 3 YPos <— 6 REPEAT 3 TIMES { DrawCircle (xPos, yPos, 2) XPos <— xPos + 2 YPos <— yPos -2
A student is writing a program to model different real-world events using simulations. Which of the following simulations will generate a result that would best be stored using a Boolean variable?
a simulation of flipping a fair coin
Which of the following code segments will move the robot to the gray square?
https://assets.learnosity.com/organisations/537/c68e9aae-12ec-45eb-b1b4-e4f97e4b3e27.JPG (2-3-3)