Comp Sci Practice questions

0.0(0)
studied byStudied by 6 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/38

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

39 Terms

1
New cards
<p><strong>2021 Practice Exam MCQ: Question 5</strong></p><p>In the flowchart below, assume that j and k are assigned integer values.</p><p>Based on the algorithm represented in the flowchart, what value is displayed if j has the initial value 3 and k has the initial value 4&nbsp;?<br>A) 7</p><p>B) 9</p><p>C) 10</p><p>D) 15</p><p></p>

2021 Practice Exam MCQ: Question 5

In the flowchart below, assume that j and k are assigned integer values.

Based on the algorithm represented in the flowchart, what value is displayed if j has the initial value 3 and k has the initial value 4 ?
A) 7

B) 9

C) 10

D) 15

D

2
New cards
<p><strong>2021 Practice Exam MCQ: Question 10</strong></p><p>What value is displayed as a result of executing the code segment?</p><p>A) 3</p><p>B) 4</p><p>C) 9 </p><p>D) 12</p>

2021 Practice Exam MCQ: Question 10

What value is displayed as a result of executing the code segment?

A) 3

B) 4

C) 9

D) 12

A

3
New cards

2021 Practice Exam MCQ: Question 22

In a certain video game, players are awarded bonus points at the end of a level based on the value of the integer variable timer. The bonus points are awarded as follows.

  • If timer is less than 30, then 500 bonus points are awarded.

  • If timer is between 30 and 60 inclusive, then 1000 bonus points are awarded.

  • If timer is greater than 60, then 1500 bonus points are awarded.

Which of the following code segments assigns the correct number of bonus points to bonus for all possible values of timer ?

Select two answers.

A)
bonus ← 500;
IF (timer ≥ 30) {
bonus ← bonus + 500;
}
IF ( timer > 60) {
bonus ← bonus + 500;
}

B)
bonus ← 1500;
IF (timer ≥ 30) {
bonus ← bonus - 500;
}

C)
IF (timer > 60) {
bonus ← 1500;
}
IF (timer ≥ 30) {
bonus ← 1000;
}
IF (timer < 30) {
bonus ← 500;

D)
IF (timer > 60) {
bonus ← 1500;
}
IF ((timer ≥ 30) && (timer ≤ 60)) {
bonus ← 1000;
}
IF (timer < 30) {
bonus ← 500;

AD

4
New cards
<p><strong>2021 Practice Exam MCQ: Question 27</strong></p><p>In the flowchart below, assume that<span> j </span>and<span> k </span>are assigned integer values. Which of the following initial values of<span> j </span>and<span> k </span>will cause the algorithm represented in the flowchart to result in an infinite loop?</p><p>A) j = -5, k = 5</p><p>B) j = 0, k = 5</p><p>C) j = 5, k = 0</p><p>D) j = 5, k = -5</p>

2021 Practice Exam MCQ: Question 27

In the flowchart below, assume that j and k are assigned integer values. Which of the following initial values of j and k will cause the algorithm represented in the flowchart to result in an infinite loop?

A) j = -5, k = 5

B) j = 0, k = 5

C) j = 5, k = 0

D) j = 5, k = -5

D

5
New cards
<p><strong>2021 Practice Exam MCQ: Question 28</strong></p><p>The following spinner is used in a game. The region labeled "blue" represents 1/4 of the spinner. The regions labeled "orange" and "purple" are equal in size. Which of the following code segments can be used to simulate the behavior of the spinner? </p><p>Select two answers.</p><p>A) <br>IF (randomNum(1, 4) = 1) <br>display blue; <br>ELSE <br>IF (randomNum (1, 2) = 1 <br>display orange;<br>ELSE <br>display purple;</p><p>B)<br>IF (randomNum(1, 4) &gt; 1) <br>display blue; <br>ELSE <br>IF (randomNum (1, 2) = 1)<br>display orange;<br>ELSE <br>display purple;</p><p>C) <br>spin ← randomNum(1, 4)<br>IF (spin = 1) <br>display blue; <br>ELSE <br>IF (spin = 2) <br>display orange;<br>ELSE <br>display purple;</p><p>D)<br>spin ← randomNum(1, 4)<br>IF (spin = 1) <br>display blue; <br>ELSE <br>spin ← randomNum(1, 2)<br>IF (spin = 2)<br>display orange;<br>ELSE <br>display purple;</p>

2021 Practice Exam MCQ: Question 28

The following spinner is used in a game. The region labeled "blue" represents 1/4 of the spinner. The regions labeled "orange" and "purple" are equal in size. Which of the following code segments can be used to simulate the behavior of the spinner?

Select two answers.

A)
IF (randomNum(1, 4) = 1)
display blue;
ELSE
IF (randomNum (1, 2) = 1
display orange;
ELSE
display purple;

B)
IF (randomNum(1, 4) > 1)
display blue;
ELSE
IF (randomNum (1, 2) = 1)
display orange;
ELSE
display purple;

C)
spin ← randomNum(1, 4)
IF (spin = 1)
display blue;
ELSE
IF (spin = 2)
display orange;
ELSE
display purple;

D)
spin ← randomNum(1, 4)
IF (spin = 1)
display blue;
ELSE
spin ← randomNum(1, 2)
IF (spin = 2)
display orange;
ELSE
display purple;

AD

6
New cards

2021 Practice Exam MCQ: Question 39

In a science experiment, result X is expected to occur 25% of the time and result Y is expected to occur the remaining 75% of the time. The following code segment is intended to simulate the experiment if there are 100 trials.

Line 1:  xCount 0
Line 2:  yCount 0
Line 3:  REPEAT 100 TIMES
Line 4:  {
Line 5:     IF(RANDOM(1, 4) = 1)
Line 6:     {
Line 7:        xCount xCount + 1
Line 8:     }
Line 9:     IF(RANDOM(1, 4) > 1)
Line 10:    {
Line 11:       yCount yCount + 1
Line 12:    }
Line 13: }
Line 14: DISPLAY("Result X occurred")
Line 15: DISPLAY(xCount)
Line 16: DISPLAY("times and result Y occurred")
Line 17: DISPLAY(yCount)
Line 18: DISPLAY("times.")

A programmer runs the code segment, and the following message is displayed.

Result X occurred 24 times and result Y occurred 70 times.

The result shows that 94 trials were counted, rather than the intended 100 trials. Which of the following changes to the code segment will ensure a correct simulation of the experiment?

A) Replacing line 9 with IF(RANDOM(1, 4) ≥ 2)

B) Replacing line 9 with ELSE

C) Interchanging lines 5 and 9

D) Interchanging lines 7 and 11

B

7
New cards

2021 Practice Exam MCQ: Question 41

The following code segment is intended to remove all duplicate elements in the list myList. The procedure does not work as intended.

j ← LENGTH(myList)
REPEAT UNTIL(j = 1)
{
IF(myList[j] = myList[j - 1])
{
REMOVE(myList, j)
}
j ← j - 1
}

For which of the following contents of myList will the procedure NOT produce the intended results?

Select two answers.

A) [10, 10, 20, 20, 10, 10]

B) [30, 30, 30, 10, 20, 20]

C) [30, 50, 40, 10, 20, 40]

D) [50, 50, 50, 50, 50, 50]

AC

8
New cards

2021 Practice Exam MCQ: Question 45

A large spreadsheet contains the following information about local restaurants. A sample portion of the spreadsheet is shown below.

  • In column B, the price range represents the typical cost of a meal, where "lo" indicates under $10, "med" indicates $11 to $30, and "hi" indicates over $30.

  • In column D, the average customer rating is set to -1.0 for restaurants that have no customer ratings.

A student is developing an algorithm to determine which of the restaurants that accept credit cards has the greatest average customer rating. Restaurants that have not yet received any customer ratings and restaurants that do not accept credit card are to be ignored.

Once the algorithm is complete, the desired restaurant will appear in the first row of the spreadsheet. If there are multiple entries that fit the desired criteria, it does not matter which of them appears in the first row.

The student has the following actions available but is not sure of the order in which they should be executed.

Action

Explanation

Filter by number of ratings

Remove entries for restaurants with no customer ratings

Filter by payment type

Remove entries for restaurants that do not accept credit cards

Sort by rating

Sort the rows in the spreadsheet on column D from greatest to least

Assume that applying either of the filters will not change the relative order of the rows remaining in the spreadsheet.

Which of the following sequences of steps can be used to identify the desired restaurant?

  1. Filter by number of ratings, then filter by payment type, then sort by rating

  2. Filter by number of ratings, then sort by rating, then filter by payment type

  3. Sort by rating, then filter by number of ratings, then filter by payment type

A) I and II only

B) I and III only

C) II and III only

D) I, II, and III

D

9
New cards

2021 Practice Exam MCQ: Question 53

Delivery trucks enter and leave a depot through a controlled gate. At the depot, each truck is loaded with packages, which will then be delivered to one or more customers. As each truck enters and leaves the depot, the following information is recorded and uploaded to a database.

  • The truck’s identification number

  • The truck’s weight

  • The date and time the truck passes through the gate

  • Whether the truck is entering or leaving the depot

Using only the information in the database, which of the following questions CANNOT be answered?

A) On which day in a particular range of dates did the greatest number of trucks enter and leave the depot?

B) What is the average number of customer deliveries made by each truck on a particular day?

C) What is the change in weight of a particular truck between when it entered and left the depot?

D) Which truck has the shortest average time spent at the depot on a particular day?

B

10
New cards

2021 Practice Exam MCQ: Question 67

A list of numbers is considered increasing if each value after the first is greater than or equal to the preceding value. The following procedure is intended to return true if numberList is increasing and return false otherwise. Assume that numberList contains at least two elements.

Line 1:  PROCEDURE isIncreasing(numberList)
Line 2:  {
Line 3:     count 2
Line 4:     REPEAT UNTIL(count > LENGTH(numberList))
Line 5:     {
Line 6:        IF(numberList[count] < numberList[count - 1])
Line 7:        {
Line 8:           RETURN(true)
Line 9:        }
Line 10:       count count + 1
Line 11:    }
Line 12:    RETURN(false)
Line 13: }

Which of the following changes is needed for the program to work as intended?

A) In line 3, 2 should be changed to 1.

B) In line 6, < should be changed to.

C) Lines 8 and 12 should be interchanged.

D) Lines 10 and 11 should be interchanged.

C

11
New cards

2023_Binary_1: Question 2

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.

Two tables are shown with two columns and fourteen rows each. The first row of each table contains the column headers from left to right, Decimal, and ASCII Character. The table on the left contains ASCII Characters capital A through capital M, and the table on the right contains ASCII characters capital N through capital Z. The left table is as follows: Decimal sixty five, character A. Decimal sixty six, character B. Decimal sixty seven, character C. Decimal sixty eight, character D. Decimal sixty nine character E. Decimal seventy, character F. Decimal seventy one character G. Decimal seventy two, character H. Decimal seventy three character I. Decimal seventy four, character J. Decimal seventy five, character K. Decimal seventy six, character L. Decimal seventy seven, character M.  The right table is as follows: Decimal seventy eight, character N. Decimal seventy nine character O. Decimal eighty, character P. Decimal eighty one, character Q. Decimal eighty two, character R. Decimal eighty three character S. Decimal eighty four, character T.  Decimal eighty five, character U. Decimal eighty six, character V. Decimal eighty seven, character W. Decimal eighty eight, character X. Decimal eighty nine character Y. Decimal ninety, character Z.

ASCII characters can also be represented by hexadecimal numbers. According to ASCII character encoding, which of the following letters is represented by the hexadecimal (base 16) number 56?

A) A

B) L

C) V

D) Y

C

12
New cards

2023_Binary_1: Question 4

A color in a computing application is represented by an RGB triplet that describes the amount of red, green, and blue, respectively, used to create the desired color. A selection of colors and their corresponding RGB triplets are shown in the following table. Each value is represented in decimal (base 10).

Color Name

RGB Triplet

indigo

 (75,   0, 130)

ivory

(255, 255, 240)

light pink

(255, 182, 193)

light yellow

(255, 255, 224)

magenta

(255,   0, 255)

neutral gray

(127, 127, 112)

pale yellow

(255, 255, 160)

vivid yellow

(255, 255,  14)

According to information in the table, what color is represented by the binary RGB triplet (11111111, 11111111, 11110000) ?

A) Ivory

B) Light Yellow

C) Neutral Gray

D) Vivid Yellow

A

13
New cards

2023_Review_AAP4: Question 5

The following table shows the value of expression based on the values of input1 and input2.

Value of input1

Value of input2

Value of expression

true

true

false

true

false

true

false

true

true

false

false

true

Which of the following expressions are equivalent to the value of expression as shown in the table?

Select two answers.

A) (NOT input1) OR (NOT input2)

B) (NOT input1) AND (NOT input2)

C) NOT (input1 OR input2)

D) NOT (input1 AND input2)

AD

14
New cards

2023_Review_AAP4: Question 8

An online game collects data about each player’s performance in the game. A program is used to analyze the data to make predictions about how players will perform in a new version of the game.

The procedure GetPrediction (idNum) returns a predicted score for the player with ID number idNum. Assume that all predicted scores are positive. The GetPrediction procedure takes approximately 1 minute to return a result. All other operations happen nearly instantaneously.

Two versions of the program are shown below.

Version I


topScore 0
idList [1298702, 1356846, 8848491, 8675309]
FOR EACH id IN idList
{
score GetPrediction (id)
IF (score > topScore)
{
topScore score
}
}
DISPLAY (topScore)

Version II


idList [1298702, 1356846, 8848491, 8675309]
topID idList[1]
FOR EACH id IN idList
{
IF (GetPrediction (id) > GetPrediction (topID))
{
topID id
}
}
DISPLAY (GetPrediction (topID))

Which of the following best compares the execution times of the two versions of the program?

A) Version I requires approximately 1 more minute to execute than version II.

B) Version I requires approximately 5 more minutes to execute than version II.

C) Version II requires approximately 1 more minute to execute than version I.

D) Version II requires approximately 5 more minutes to execute than version I.

D

15
New cards

2023_Review_AAP4: Question 9

Consider the two programs below.

The figure presents two programs, labeled Program A and Program B, each with two blocks of code that consist of 4 lines. Throughout the second block of code in each program there are nested blocks of code, as follows. Program A. Line 1: [begin block] i ← 1 [end block] [Begin Block] Line 2: REPEAT UNTIL [begin block] i is greater than 10 [end block] [begin block] Line 3: [begin block] DISPLAY [begin block] i [end block] [end block] Line 4: [begin block] i ← i + 1 [end block] [end block] [End Block] Program B. Line 1: [begin block] i ← 0 [end block] [Begin Block] Line 2: REPEAT UNTIL [begin block] i ≥ 10 [end block] [begin block] Line 3:  [begin block] i ← i + 1 [end block] Line 4: [begin block] DISPLAY [begin block] i [end block] [end block] [End Block]

Which of the following best compares the values displayed by programs A and B?

Responses

A) Program A and program B display identical values in the same order.

B) Program A and program B display the same values in different orders.

C) Program A and program B display the same number of values, but the values differ.

D) Program B displays one more value than program A.

A

16
New cards

2023_Review_AAP5: Question 2

The list wordList contains a list of 10 string values. Which of the following is a valid index for the list?

A) -1

B) “hello”

C) 2.5

D) 4

D

17
New cards

2023_Review_AAP5: Question 6

An office building has two floors. A computer program is used to control an elevator that travels between the two floors. Physical sensors are used to set the following Boolean variables.

The figure shows a table with 2 columns and 5 rows. The top row contains the column labels, from left to right; column 1, Variable; column 2, Description. From top to bottom, the data is as follows: Row 2; Variable, onFloor1, Description, set to true if the elevator is stopped on floor 1; otherwise set to false. Row 3; Variable, onFloor2, Description, set to true if the elevator is stopped on floor 2; otherwise set to false. Row 4; Variable, callTo1, Description, set to true if the elevator is called on floor 1; otherwise set to false. Row 5; Variable, callTo2, Description, set to true if the elevator is called on floor 2; otherwise set to false.

The elevator moves when the door is closed and the elevator is called to the floor that it is not currently on. Which of the following Boolean expressions can be used in a selection statement to cause the elevator to move?

A) (onFloor1 AND callTo2) AND (onFloor2 AND callTo1)

B) (onFloor1 AND callTo2) OR (onFloor2 AND callTo1)

C) (onFloor1 OR callTo2) AND (onFloor2 OR callTo1)

D) (onFloor1 OR callTo2) OR (onFloor2 OR callTo1)

B

18
New cards

2023_Review_AAP6: Question 1

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

19
New cards

2023_Review_AAP6: Question 8

Consider the following procedures for string manipulation.

Procedure Call

Explanation

concat(str1, str2)

Returns a single string consisting of str1 followed by str2. For example, concat("key", "board") returns "keyboard".

substring(str, start, length)

Returns a substring of consecutive characters from str, starting with the character at position start and containing length characters. The first character of str is located at position 1. For example, substring("delivery", 3, 4) returns "live".

len(str)

Returns the number of characters in str. For example, len("pizza") returns 5.

Assume that the string oldString contains at least 4 characters. A programmer is writing a code segment that is intended to remove the first two characters and the last two characters from oldString and assign the result to newString.

For example, if oldString contains "student", then newString should contain "ude".

Which of the following code segments can be used to assign the intended string to newString ?

Select two answers.

A) newString ← substring(oldString, 3, len(oldString) - 4)

B) newString ← substring(oldString, 3, len(oldString) - 2)

C) tempString ← substring(oldString, 3, len(oldString) - 2)
newString ← substring(tempString, 1, len(tempString) - 2)

D) tempString1 ← substring(oldString, 1, 2)
tempString2 ← substring(oldString, len(oldString) - 2, 2)
newString ← concat(tempString1, tempString2)

C

20
New cards

2023_Review_AAP6: Question 10

A teacher stores the most recent quiz scores for her class in the list scores. The first element in the list holds the maximum possible number of points that can be awarded on the quiz, and each remaining element holds one student’s quiz score. Assume that scores contains at least two elements. Which of the following code segments will set the variable found to true if at least one student scored the maximum possible number of points on the quiz and will set found to false otherwise?

Responses

A)The figure presents four blocks of code that consist of 7 lines. Throughout the blocks of code there are nested blocks of code, as follows. Line 1: [begin block] len ← LENGTH [begin block] scores [end block] - 1 [end block] Line 2: [begin block] found ← false [end block] Line 3: [begin block] index ← 2 [end block] [begin block] Line 4: REPEAT len TIMES [begin block] [begin block] Line 5: IF [begin block] scores [begin block] index [end block] = scores [begin block] 1 [end block] [end block] [begin block] Line 6: [begin block] found ← true [end block] [end block] [end block] Line 7: [begin block] index ← index + 1 [end block] [end block] [end block]

B)The figure presents four blocks of code that consist of 7 lines. Throughout the blocks of code there are nested blocks of code, as follows. Line 1: [begin block] len ← LENGTH [begin block] scores [end block] [end block] Line 2: [begin block] found ← false [end block] Line 3: [begin block] index ← 1 [end block] [begin block] Line 4: REPEAT len TIMES [begin block] [begin block] Line 5: IF [begin block] scores [begin block] index [end block] = scores [begin block] 1 [end block] [end block] [begin block] Line 6: [begin block] found ← true [end block] [end block] [end block] Line 7: [begin block] index ← index + 1 [end block] [end block] [end block]

C)The figure presents four blocks of code that consist of 7 lines. Throughout the blocks of code there are nested blocks of code, as follows. Line 1: [begin block] len ← LENGTH [begin block] scores [end block] [end block] Line 2: [begin block] found ← false [end block] Line 3: [begin block] index ← 2 [end block] [begin block] Line 4: REPEAT UNTIL [begin block] index greater than or equal to len [end block] [begin block] [begin block] Line 5: IF [begin block] scores [begin block] index [end block] = scores [begin block] 1 [end block] [end block] [begin block] Line 6: [begin block] found ← true [end block] [end block] [end block] Line 7: [begin block] index ← index + 1 [end block] [end block] [end block]

D) The figure presents two blocks of code that consist of 4 lines. Throughout the blocks of code there are nested blocks of code, as follows. Line 1: [begin block] found ← false [end block] [begin block] Line 2: FOR EACH value IN scores [begin block] [begin block] Line 3: IF [begin block] value = scores [begin block] 1 [end block] [end block] [begin block] Line 4: [begin block] found ← true [end block] [end block] [end block] [end block] [end block]

A

21
New cards

2023_Review_CRD3: Question 3

A homework assignment consists of 10 questions. The assignment is graded as follows.

Number of

Correct Answers

Grade

9–10

check plus

7–8

check

Under 7

check minus

Let numCorrect represent the number of correct answers for a particular student. The following code segment is intended to display the appropriate grade based on numCorrect. The code segment does not work as intended in all cases.

The figure presents one block of code that consists of 7 lines. Throughout the block of code there are nested blocks of code, as follows. [Begin Block] Line 1: IF [Begin Block] numCorrect greater than 7 [End Block] [Begin Block] [Begin Block] Line 2: IF [Begin Block] numCorrect greater than or equal to 9 [End Block] [Begin Block] Line 3: [Begin Block] DISPLAY [Begin Block] “check plus” [End Block] [End Block] [End Block] Line 4: ELSE [Begin Block] Line 5: [Begin Block] DISPLAY [Begin Block] “check minus” [End Block] [End Block] [End Block] [End Block] [End Block] Line 6: ELSE [Begin Block] Line 7: [Begin Block] DISPLAY [Begin Block] “check” [End Block] [End Block] [End Block] [End Block]

For which of the following values of numCorrect does the code segment NOT display the intended grade?

Select two answers.

A) 9

B) 8

C) 7

D) 6

BD

22
New cards

2023_Review_MiniTest1: Question 4

Which of the following are true statements about the data that can be represented using binary sequences?

  1. Binary sequences can be used to represent strings of characters.

  2. Binary sequences can be used to represent colors.

  3. Binary sequences can be used to represent audio recordings.

A)I only

B) I and II only

C) II and III only

D) I, II, and III

D

23
New cards

2023_Review_MiniTest1: Question 7

A large spreadsheet contains the following information about the books at a bookstore. A sample portion of the spreadsheet is shown below.

 

A

Book Title

B

Author

C

Genre

D

Number of

Copies in Stock

E

Cost

(in dollars)

1

Little Women

Louisa May Alcott

Fiction

3

13.95

2

The Secret Adversary

Agatha Christie

Mystery

2

12.95

3

A Study in Scarlet

Arthur Conan Doyle

Mystery

0

8.99

4

The Hound of the Baskervilles

Arthur Conan Doyle

Mystery

1

8.95

5

Les Misérables

Victor Hugo

Fiction

1

12.99

6

Frankenstein

Mary Shelley

Horror

2

11.95

An employee wants to count the number of books that meet all of the following criteria.

  • Is a mystery book

  • Costs less than $10.00

  • Has at least one copy in stock

For a given row in the spreadsheet, suppose genre contains the genre as a string, num contains the number of copies in stock as a number, and cost contains the cost as a number. Which of the following expressions will evaluate to true if the book should be counted and evaluates to false otherwise?

A) (genre = "mystery") AND ((1 ≤ num) AND (cost < 10.00))

B) (genre = "mystery") AND ((1 < num) AND (cost < 10.00))

C) (genre = "mystery") OR ((1 ≤ num) OR (cost < 10.00))

D) (genre = "mystery") OR ((1 < num) OR (cost < 10.00))

A

24
New cards

2023_Review_MiniTest1: Question 11

A programmer is creating an algorithm that will be used to turn on the motor to open the gate in a parking garage. The specifications for the algorithm are as follows.

  • The gate should not open when the time is outside of business hours.

  • The motor should not turn on unless the gate sensor is activated.

  • The motor should not turn on if the gate is already open.

Which of the following algorithms can be used to open the gate under the appropriate conditions?

Responses

A) Check if the time is outside of business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is closed. If it is, turn on the motor.

B) Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is, turn on the motor.

C) Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is not, check if the gate is open. If it is not, turn on the motor.

D) Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is not, turn on the motor.

D

25
New cards

2023_Review_MiniTest1: Question 13

Consider the following code segment.

The figure presents twelve blocks of code that consist of  12 total lines. Line 1: [begin block] a  ← 10 [end block] Line 2: [begin block] b  ← 20 [end block] Line 3: [begin block] c  ← 30 [end block] Line 4: [begin block] d  ← 40 [end block] Line 5: [begin block] x  ← 20 [end block] Line 6: [begin block] b  ← x plus b [end block] Line 7: [begin block] a  ← x plus 1 [end block] Line 8: [begin block] d  ← c plus d divided by 2 [end block] Line 9: [begin block] DISPLAY [begin block] a [end block] [end block] Line 10: [begin block] DISPLAY [begin block] b [end block] [end block] Line 11: [begin block] DISPLAY [begin block] c [end block] [end block] Line 12: [begin block] DISPLAY [begin block] d [end block] [end block]

What is displayed as a result of executing the code segment?

A) 10 20 30 40

B) 21 30 40 50

C) 21 40 30 40

D) 21 40 30 35

D

26
New cards

2023_Review_MiniTest1: Question 19

In the flowchart below, assume that j and k are assigned integer values.

 

The figure presents a flow chart of an algorithm. Beginning at the top of the flow chart, the algorithm begins with a step labeled Start, which flows into a processing step labeled result ← 0, which flows into a conditional step labeled k = 0. If the condition is true, the process flows into a processing step labeled DISPLAY (result), which flows into a step labeled End. If the condition is false, the process flows into a processing step labeled result ← result + j and k ← k - 1, which flows back into the conditional step labeled k = 0.

Based on the algorithm represented in the flowchart, what value is displayed if j has the initial value 3 and k has the initial value 4 ?

A) 7

B) 9

C) 10

D) 12

D

27
New cards

2023_Review_MiniTest1: Question 24

Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case.

Which of the following are true statements about how the Internet enables crowdsourcing?

I. The Internet can provide crowdsourcing participants access to useful tools, information, and professional knowledge.

II. The speed and reach of the Internet can lower geographic barriers, allowing individuals from different locations to contribute to projects.

III. Using the Internet to distribute solutions across many users allows all computational problems to be solved in reasonable time, even for very large input sizes.

Responses

A) I and II only

B) I and III only

C) II and III only

D) I, II, and III

A

28
New cards

2023_Review_MiniTest2: Question

A)

B)

C)

D)

29
New cards

2023_Review_AAP3: Question 4

Assume that the variables alpha and beta each are initialized with a numeric value. Which of the following code segments can be used to interchange the values of alpha and beta using the temporary variable temp ?

  1. The figure presents 3 blocks of code. Line 1: [begin block] temp ← alpha [end block] Line 2: [begin block] alpha ← beta [end block] Line 3: [begin block] beta ← temp [end block]

  2. The figure presents 3 blocks of code. Line 1: [begin block] temp ← alpha [end block] Line 2: [begin block] beta ← alpha [end block] Line 3: [begin block] alpha ← temp [end block]

  3. The figure presents 3 blocks of code. Line 1: [begin block] temp ← beta [end block] Line 2: [begin block] beta ← alpha [end block] Line 3: [begin block] alpha ← temp [end block]

A) I and II only

B) I and III only

C) II and III only

D) I, II. and III

B

30
New cards

2023_Review_AAP3: Question 8

A biologist wrote a program to simulate the population of a sample of bacteria. The program uses the following procedures.

Procedure Call

Explanation

InitialPopulation ()

Returns the number of bacteria at the start of the simulation

NextPopulation (currPop)

Based on the current value of currPop, returns the number of bacteria after one hour

Code for the simulation is shown below.

hours 0
startPop InitialPopulation ()
currentPop startPop
REPEAT UNTIL ((hours ≥ 24) OR (currentPop ≤ 0))
{
currentPop NextPopulation (currentPop)
hours hours + 1
}
DISPLAY (currentPop - startPop)

Which of the following are true statements about the simulation?

  1. The simulation continues until either 24 hours pass or the population reaches 0.

  2. The simulation displays the average change in population per hour over the course of the simulation.

  3. The simulation displays the total population at the end of the simulation.

A) I only

B) II only

C) III only

D) I and II

A

31
New cards

2024_Review_DAT1: Question 2

A color in a computing application is represented by an RGB triplet that describes the amount of red, green, and blue, respectively, used to create the desired color. A selection of colors and their corresponding RGB triplets are shown in the following table. Each value is represented in decimal (base 10).

Color Name

RGB Triplet

indigo

 (75,   0, 130)

ivory

(255, 255, 240)

light pink

(255, 182, 193)

light yellow

(255, 255, 224)

magenta

(255,   0, 255)

neutral gray

(127, 127, 112)

pale yellow

(255, 255, 160)

vivid yellow

(255, 255,  14)

What is the binary RGB triplet for the color indigo?

A) (00100101, 00000000, 10000010)

B) (00100101, 00000000, 01000001)

C) (01001011, 00000000, 10000010)

D) (01001011, 00000000, 01000001)

C

32
New cards

Developing Procedures Quiz (MCQs): Question 2

A computer program contains code in several places that asks a user to enter an integer within a specified range of values. The code repeats the input request if the value that the user enters is not within the specified range. A programmer would like to create a procedure that will generalize this functionality and can be used throughout the program. The correct use of the procedure is shown below, where min is the least acceptable value, max is the greatest acceptable value, and promptString is the string that should be printed to prompt the user enter a value.

inputVal getRange(min, max, promptString)

Which of the following is a correct implementation of the getRange procedure?

A)

PROCEDURE getRange(min, max, promptString)
{
DISPLAY(promptString)
RETURN(INPUT())
}


B) PROCEDURE getRange(min, max, promptString)
{
DISPLAY(promptString)
x INPUT()
RETURN(x)
}

C)

PROCEDURE getRange(min, max, promptString)
{
DISPLAY(promptString)
x INPUT()
REPEAT UNTIL(x ≥ min AND x ≤ max)
{
DISPLAY(promptString)
x INPUT()
}
}

D)

PROCEDURE getRange(min, max, promptString)
{
DISPLAY(promptString)
x INPUT()
REPEAT UNTIL(x ≥ min AND x ≤ max)
{
DISPLAY(promptString)
x INPUT()
}
RETURN(x)
}

33
New cards

Identifying and Correcting Errors Quiz (MCQs): Question 2

The following procedure is intended to return true if the list of numbers myList contains only positive numbers and is intended to return false otherwise. The procedure does not work as intended.

PROCEDURE allPositive(myList)
{
index 1
len LENGTH(myList)
REPEAT len TIMES
{
IF(myList[index] > 0)
{
RETURN(true)
}
index index + 1
}
RETURN(false)
}

For which of the following contents of myList does the procedure NOT return the intended result?

A) [-3, -2, -1]

B) [-2, -1, 0]

C) [-1, 0, 1]

D) [1, 2, 3]

D

34
New cards

OPT_2024_Review_CRD2: Question

Directions: For the question or incomplete statement below, two of the suggested answers are correct. For this question, you must select both correct choices to earn credit. No partial credit will be earned if only one correct choice is selected. Select the two that are best in each case.

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.

The program consists of 11 lines. Begin program Line 1: PROCEDURE Multiply, open parenthesis, x comma y, close parenthesis Line 2: open brace Line 3: count, left arrow, 0 Line 4: result, left arrow, 0 Line 5: REPEAT UNTIL, open parenthesis, count equals y, close parenthesis Line 6: open brace Line 7: result, left arrow, result plus x Line 8: count, left arrow, count plus 1 Line 9: close brace Line 10: RETURN, open parenthesis, result, close parenthesis Line 11: close brace End program.

A programmer suspects that an error in the program is caused by this procedure. Under which of the following conditions will the procedure NOT return the correct product?

Select two answers.

A) When the values of x and y are both positive

B)When the values of x is positive and y is negative

C) When the values of x is negative and y is positive

D) When the values of x and y are both negative

BD

35
New cards

OPT_2024_Review_CRD2: Question

Assume that the list of numbers nums has more than 10 elements. The program below is intended to compute and display the sum of the first 10 elements of nums.

Line 1: i 1

Line 2: sum 0

Line 3: REPEAT UNTIL (i > 10)

Line 4: {

Line 5:    i i + 1

Line 6:    sum sum + nums[i]

Line 7: }

Line 8: DISPLAY (sum)

Which change, if any, is needed for the program to work as intended?

A) Lines 1 and 2 should be interchanged.

B) Line 3 should be changed to REPEAT UNTIL (i ≥ 10).

C) Lines 5 and 6 should be interchanged.

D) No change is needed; the program works correctly.

C

36
New cards

OPT_2024_Review_DAT2: Question 3

ASCII is a character-encoding scheme that uses 7 bits to represent each character. The decimal (base 10) values 65 through 90 represent the capital letters A through Z, as shown in the table below.

Two tables are shown, each with two columns. The left column of each is titled Decimal and the right ASCII Character. The first table has values 65 through 77 in the left column and letters A through M in the right column. The second table has values 78 through 90 in the left column and letters N through Z in the right column.

What ASCII character is represented by the binary (base 2) number 1001010 ?

A) H

B) I

C) J

D) K

C

37
New cards

OPT_2024_Review_DAT2: Question 9

A programmer is writing a program that is intended to be able to process large amounts of data. Which of the following considerations is LEAST likely to affect the ability of the program to process larger data sets?

A) How long the program takes to run

B) How many programming statements the program contains

C) How much memory the program requires as it runs

D) How much storage space the program requires as it runs

B

38
New cards

OPT_2024_Review_IOC2: Question 7

A chain of retail stores uses software to manage telephone calls from customers. The system was recently upgraded. Customers interacted with the original system using their phone keypad. Customers interact with the upgraded system using their voice.

The upgraded system (but not the original system) stores all information from the calling session in a database for future reference. This includes the customer’s telephone number and any information provided by the customer (name, address, order number, credit card number, etc.).

The original system and the upgraded system are described in the following flowcharts. Each flowchart uses the following blocks.

The figure presents a flow chart of a system titled “Original System.” Beginning at the top of the flow chart, the system begins with a step labeled “Start,” which flows into a step labeled “Customer hears prerecorded message with answers to common questions (for example, store hours).” The process flows into another step labeled “Customer hears list of departments and selects one using a phone keypad.” The process flows into a conditional step labeled “Call is during business hours?” If the condition is Yes, the process flows into a result labeled “Customer is transferred to a representative from the department they selected.” If the condition is No, the process flows into a result labeled “Customer is prompted to leave a message for the representative of the department they selected.”

The figure presents a flow chart of a system titled “Upgraded System.” Beginning at the top of the flow chart, the system begins with a step labeled “Start,” which flows into a step labeled “Customer prompted to describe the issue.” The process flows into another step labeled “Customer describes the issue by voice.” The process flows into a conditional step labeled “System can identify customer’s issue?” If the condition is Yes, the process flows into another conditional step labeled “Issue requires human response?” If the condition is Yes, the process flows into another conditional step labeled “Call is during business hours?” If the condition is Yes, the process flows into a result labeled “Customer is transferred to a representative from a relevant department.” If the condition is No, the process flows into a result labeled “Customer is prompted to leave a message, which is then routed to a representative from a relevant department.” If the condition to the step labeled “Issue requires human response?” is No, the process flows into a result labeled “System plays an appropriate recording to the customer.” If the condition to the step labeled “System can identify customer’s issue?” is No, the process flows into another conditional step labeled “Call is during business hours?” If the condition is Yes, the process flows into a result labeled “Customer is transferred to a human operator.” If the condition is No, the process flows into a result labeled “Customer is asked to call back during business hours.”Of the following potential benefits, which is LEAST likely to be provided by the upgraded system?

A) Human representatives will not be needed to respond to some inquiries.

B) The company will be able to provide a human representative for any incoming call.

C) Customers are likely to spend less time listening to information not relevant to their issue.

D) Customers will be unable to mistakenly select the incorrect department for their particular issue.

B

39
New cards

OPT_2024_Review_IOC2: Question 12

StreamPal is an audio-streaming application for mobile devices that allows users to listen to streaming music and connect with other users who have similar taste in music. After downloading the application, each user creates a username, personal profile, and contact list of friends who also use the application.

The application uses the device’s GPS unit to track a user’s location. Each time a user listens to a song, the user can give it a rating from 0 to 5 stars. The user can access the following features for each song that the user has rated.

  • A list of users on the contact list who have given the song the same rating, with links to those users’ profiles

  • A map showing all other users in the area who have given the song the same rating, with links to those users’ profiles

A basic StreamPal account is free, but it displays advertisements that are based on data collected by the application. For example, if a user listens to a particular artist, the application may display an advertisement for concert tickets the next time the artist comes to the user’s city. Users have the ability to pay a monthly fee for a premium account, which removes advertisements from the application.

Which of the following is most likely to be a data privacy concern for StreamPal users?

A) Users of the application are required to rate songs in order to enable all of the application’s features.

B) Users of the application may have the ability to determine information about the locations of users that are not on their contact list.

C) Users of the application may not be able to use the application if they are located in an area with a poor Internet connection.

D) Users of the application may not have similar music taste to any other users on their contact list.

B