Computer Science Exam Questions and Answers: Latest Version, Exams of Computer Science

A collection of exam questions and answers related to computer science concepts. It covers topics such as programming, algorithms, data structures, and computer security. The questions are designed to test understanding of fundamental principles and problem-solving skills. Suitable for students preparing for computer science exams or those seeking to reinforce their knowledge.

Typology: Exams

2024/2025

Available from 03/25/2025

Martin-Ray-1
Martin-Ray-1 🇺🇸

4.7

(12)

9.8K documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Latest Version Exam
Comp Science Online Exam Latest
Upload Questions with Answers.
Recently Jessica gave a speech while running for ocer of her club. Her debate coach wants Jessica
to rene her public speaking skills by analyzing a transcript he made of her speech to identify her
use of specic ller words not necessary to convey her message. What results will the following
program segment create for Jessica's consideration if the variable k represents a word to search? -
Correct Answer: ✅✅The program will count the number of times the word "like" was said by
Jessica.
A video-streaming service maintains a database of information about its customers and the videos
they have watched.
The program below analyzes the data in the database and compares the number of viewers of
science fiction videos to the number of viewers of videos of other genres. It uses the procedure
Analysis (category), which returns the number of unique users who viewed videos of a given
category in the past year. The
Analysis procedure takes approximately 1 hour to return a result, regardless of the number of
videos of the given genre. All other operations happen nearly instantaneously.
sciFiFans ← Analysis ("science fiction")
genreList ← ["comedy", "drama", "mystery", "romance"] FOR EACH genre IN genreList
{
IF (Analysis (genre) > sciFiFans)
{
DISPLAY (genre)
}
}
Which of the following best approximates the amount of time it takes the program to execute? -
Correct Answer: ✅✅5 hours
An online retailer uses an algorithm to sort a list of n items by price. The table below shows the
approximate number of steps the algorithm takes to sort lists of different sizes.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Computer Science Exam Questions and Answers: Latest Version and more Exams Computer Science in PDF only on Docsity!

Comp Science Online Exam Latest

Upload Questions with Answers.

Recently Jessica gave a speech while running for ocer of her club. Her debate coach wants Jessica to rene her public speaking skills by analyzing a transcript he made of her speech to identify her use of specic ller words not necessary to convey her message. What results will the following program segment create for Jessica's consideration if the variable k represents a word to search? - Correct Answer: ✅✅The program will count the number of times the word "like" was said by Jessica.

A video-streaming service maintains a database of information about its customers and the videos they have watched.

The program below analyzes the data in the database and compares the number of viewers of science fiction videos to the number of viewers of videos of other genres. It uses the procedure Analysis (category), which returns the number of unique users who viewed videos of a given category in the past year. The

Analysis procedure takes approximately 1 hour to return a result, regardless of the number of videos of the given genre. All other operations happen nearly instantaneously.

sciFiFans ← Analysis (" science fiction")

genreList ← ["comedy", "drama", "mystery", "romance"] FOR EACH genre IN genreList

{

IF (Analysis (genre) > sciFiFans)

{

DISPLAY (genre)

}

}

Which of the following best approximates the amount of time it takes the program to execute? - Correct Answer: ✅✅5 hours

An online retailer uses an algorithm to sort a list of n items by price. The table below shows the approximate number of steps the algorithm takes to sort lists of different sizes.

Based on the values in the table, which of the following best characterizes the algorithm for very large values of n? - Correct Answer: ✅✅The algorithm runs in reasonable time.

Referring to the scores list in question 14 and the APCSP Lists Operations, select the pseudocode to insert the value at the middle of the

scoreslist. - Correct Answer: ✅✅a INSERT (scores, 6, 66)

A student wants to create an algorithm that can determine, given any program and program input, whether or not the program will go into an infinite loop for that input.

The problem the student is attempting to solve is considered an undecidable problem. Which of the following is true? - Correct Answer: ✅✅It is not possible to create an algorithm that will solve the problem for all programs and inputs.

CHECK THIS

Which of the following is NOT accurate information about cookies? - Correct Answer: ✅✅Cookies indicate that the system may have been compromised by a virus or threat.

Bella is writing a program that will ask the user a series of questions pulled randomly from a list. The responses will be used for completing an output procedure. She realizes that this program should have a control structure in order to limit the number of questions to be posed to the user. Which control structure will allow Bella to limit the number of questions? - Correct Answer: ✅✅Repeat loop

A population researcher is interested in predicting the number of births that will occur in a particular community. She created a computer model that uses data from the past ten years, including number of residents and the number of babies born. The model predicted that there would be 200 births last year, but the actual number of births last year was only 120. Which of the following strategies is LEAST likely to provide a more accurate prediction? - Correct Answer: ✅✅Removing as many details from the model as possible so that calculations can be performed quickly

CHECK THIS

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 - Correct Answer: ✅✅II and III

What is the output of the following program segment?

s ß "Hula-hoops were a fad." DISPLAY (s.indexOf("hoo")) - Correct Answer: ✅✅ 6

A flowchart is a way to visually represent an algorithm. The flowchart below is used by an apartment rentalWeb 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 owchart? - Correct Answer: ✅✅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? - Correct Answer: ✅✅An archive containing previous versions of the e-book

Which of the following describes how a distributed denial-of-service (DDoS) attack is most likely to compromise an online store'sWeb site? - Correct Answer: ✅✅By preventing customers from placing orders

The CPU (central processing unit) of a computer is a(n): - Correct Answer: ✅✅Integrated circuit

Internet packets are made up of sequences that are sent through the lowest layer of OSI. - Correct Answer: ✅✅binary

Which of the following is an example of symmetric encryption? - Correct Answer: ✅✅Finn and Gwen develop a system that maps each letter of the alphabet to a unique symbol using a secret

key. Finn uses the key to write a message to Gwen where each letter is replace

Which of the following is a true statement about Internet communication? - Correct Answer: ✅✅Every device connected to the Internet is assigned an Internet protocol (IP) address.

Which of the following best describes the role of the Internet Engineering - Correct Answer: ✅✅Developing standards and protocols for Internet communication

Consider the following program.

count = 1

sum = 0

repeat 10 times

{

sum = sum + count count = count +

}

display sum

Which of the following describes the result of executing the program? - Correct Answer: ✅✅The program displays the sum of the odd integers from 1 to 19

A spinner is divided into three sections. The sector labeled Red is four times as large as each of the sectors labeled Blue and Yellow, which are of equal size.

The procedure below is intended to simulate the behavior of the spinner.

Which of the following can be used to replace so that the procedure correctly simulates the spinner? - Correct Answer: ✅✅(swis) CHEESE

spin arrow random 1,

if spin is 1

return yellow

ROTATE_LEFT ( )

} ELSE

ROTATE_RIGHT ( )

For which of the grids does the program correctly move the robot to the gray square? - Correct Answer: ✅✅grid 1 only

The two code segments below are each intended to display the average of the numbers in the list numList. Assume that numList contains more than one value.

Which of the following best describes the two code segments? - Correct Answer: ✅✅Both code segments display the correct average, but code segment I requires more arithmetic operations than code segment II.

Consider the code segment below:

line 3 t1 ß 0 line 4 t2 ß 0 line 5 t3 ß 0 line 6 a ß 0.

line 7 a ß (t1 + t2 + t3)/

line 8 DISPLAY a

What type of data may be entered for t1-t3? - Correct Answer: ✅✅yo yo you figure it out

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 nal exam, so his original midterm and nal exam scores are added to compute his total points.

Josena does better on the nal exam than on the midterm exam, so her nal exam score replaces her midterm exam score in the total points calculation.

The teacher has data representing the scores of thousands of students. For each student, the data contain the student - Correct Answer: ✅✅i, ii , and iii

Which of the following describes a benefit of using hexadecimal numbers instead of binary numbers to represent data? - Correct Answer: ✅✅A hexadecimal representation of a value generally requires fewer digits than a binary representation of the same value.

In determining the best route to take on recent trip using a maps application gave the user three options based on trac patterns, road construction, and roadways. Choosing the best alternative among the three possible routes is considered which of the following: - Correct Answer: ✅✅Heuristic solution

A program is created to perform arithmetic operations on positive and negative integers. The program contains the following incorrect procedure, which is intended to return the product of the integers x and y.

RETURN ()

Which of the following can be used to replace so that the procedure works as intended? - Correct Answer: ✅✅counter > 0.5 * total

A model is a(n) of an actual system - Correct Answer: ✅✅abstraction

The question below uses a robot grid of squares. The robot is represented as a triangle, which initially starts in the top-left square facing toward the right side of the grid - Correct Answer: ✅✅GG

The procedure DrawCircle (x, y, r) can be used to draw a circle on a coordinate grid. The circle is centered at the coordinate (x, y) and has a radius of r units. The procedure will be used to draw the following figure on a coordinate grid. - Correct Answer: ✅✅xPos 3

yPos ← 6

REPEAT 3 TIMES

{

}

DrawCircle (xPos, yPos, 2) xPos ← xPos + 2

yPos ← yPos - 2

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? - Correct Answer: ✅✅NOT (P AND Q)

The binary search algorithm makes which vital assumption about the data list being considered? - Correct Answer: ✅✅The data is pre-sorted.

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 code segment below uses the procedure GoalReached, which evaluates to true if the robot is in the gray square and evaluates to false otherwise.

REPEAT UNTIL (GoalReached ())

{

}

Which of the following replacements for can be used to move the robot to the gray square? - Correct Answer: ✅✅IF (CAN_MOVE (right))

{

ROTATE_RIGHT

}

MOVE_FORWARD ()

Which of the following is an underlying assumption that is made when Moore's law is used? - Correct Answer: ✅✅As computer hardware improves, future computers will be able to run faster than current computers.

A program contains the following procedures for string manipulation.

Which of the following expressions can be used to generate the string "Happy"? - Correct Answer: ✅✅Concat (Substring ("Harp", 1, 2), Substring ("Puppy", 3, 3))

Which of the following best characterizes a high-level programming language? - Correct Answer: ✅✅A language that uses multiple abstractions to manage complexity

In a certain science experiment, 75 percent of trials are expected to be successful and 25 percent of trials are expected to be unsuccessful. The program below is intended to simulate the results of repeated trials of the experiment.

successful ← 0 unsuccessful ← 0

REPEAT 1000 TIMES

- Procedure Cube (n) returns the value n

Which of the following procedures is a generalization of the procedures described above? - Correct Answer: ✅✅Procedure Power (n, m), which returns the value n^m

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? - Correct Answer: ✅✅ 8

A free online encyclopedia contains articles that can be written and edited by any user. Which of the following are advantages the online encyclopedia has over a traditional paper-based encyclopedia?

Select two answers. - Correct Answer: ✅✅The ability to quickly update encyclopedia content as new information becomes available

The ability to have a larger number of perspectives re ected in the encyclopedia content

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? - Correct Answer: ✅✅Using lossy compression software to reduce the size requirements of the data being stored

Consider the following code segment. What is displayed as a result of execution?

d ß 10 e ß 20 f ß 30 e ß d

DISPLAY (e) - Correct Answer: ✅✅10 20

A programmer wishes to create a program for calculating his grades in courses and to verify his GPA. Which data type is the most appropriate? - Correct Answer: ✅✅Real Number

Consider the pseudo code segment below.

//Read and average three numbers

If (avg > 89.45)

Print "Congratulations, you made an A!" Else

Print "Your average is" + avg "."

What selection criteria is being used to determine the output? (choose 2)] - Correct Answer: ✅✅avg results above 89.

Logical condition

This logic is used to describe behavior of gates and circuits: - Correct Answer: ✅✅boolean

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? - Correct Answer: ✅✅Max (Max (a, b), c)

Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in

Which of the following methods are useful to convert numbers from one base to any other base? - Correct Answer: ✅✅Remainder Division

Select the language supported by the ASCII character set: - Correct Answer: ✅✅English

Ebony is searching for an Internet provider. Which is her best consideration when selecting from her options. - Correct Answer: ✅✅Both Internet speed and latency

A bank customer receives an e-mail from a sender claiming to be a bank employee. The e-mail asks the customer to provide personal information and to call a phone number if he or she has any questions. The

customer suspects the e-mail might be a phishing attempt. Which of the following responses is most likely to be a privacy risk for the bank customer? - Correct Answer: ✅✅Calling the phone number given in the e-mail and providing the personal information over the phone

A student wrote the following code for a guessing game.

While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction WIN←TRUE somewhere in the code. Where could win < -true be inserted so that the code segment works as intended? - Correct Answer: ✅✅Between line 9 and line 10

Data representation is as follows: is continuous; is broken in pieces. - Correct Answer: ✅✅analog digital

The diagram below shows a circuit composed of three logic gates. Each gate takes two inputs and produces a single output. - Correct Answer: ✅✅A = true, B = false, C = false, D = false

Consider the program below which outputs the season.

What is the output results with the initial values of x is 3 and y is 5? - Correct Answer: ✅✅Winter

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.

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 midtermExam and finalExam. The procedure Max (a, 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 th - Correct Answer: ✅✅adjustedTotal Max (midtermExam, nalExam) + nalExam

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? - Correct Answer: ✅✅The procedure returns true no matter what the input value is.

Sam needs to send a picture via email and wants it to arrive in best quality, therefore, he should select which lossless compression image format? - Correct Answer: ✅✅png

The program below is intended to count the number of prime numbers in a list called numbers and display the result. The program uses the procedure isPrime (n), which returns true if n is a prime number

and false otherwise.

The program does not work as intended.

Which two lines of code should be removed so that the program will work as intended? Select two answers. - Correct Answer: ✅✅Line 4

Line 9

A musician is creating a song using audio samples. Which of the following actions will minimize the risk of a copyright violation when creating sample-based music? - Correct Answer: ✅✅Using samples published with a no-rights-reserved Creative Commons license

III. The name of the person who took the most recent photo - Correct Answer: ✅✅I and II only

What is output by the code below?

Display( 20 mod 4) + 3 - Correct Answer: ✅✅ 3

The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the top-left square of the grid and facing downward. The robot can move into a white or gray square, but cannot move into a black region.

Which of the following code segments can be used to move the robot to the gray square? - Correct Answer: ✅✅MOVE_FORWARD ( )

ROTATE_LEFT ( )

REPEAT 2 TIMES

{

}

ROTATE_RIGHT REPEAT 3 TIMES {

MOVE_FORWARD ( ) MOVE_FORWARD ( ) ROTATE_LEFT ( )

}

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 GoalReached, which returns true if the robot is in the gray square and returns false otherwise.

Which of the following statements is true? - Correct Answer: ✅✅Both program I and program II correctly move the robot to the gray square.

Which of the following would be the best use of citizen science? - Correct Answer: ✅✅An experiment that requires data measurements to be taken in many di erent locations

Select the best description for a control structure - Correct Answer: ✅✅a An order that speci es the sequence in which program instructions are to be executed