unit 3 quiz 1and2 comp sci

¡Supera tus tareas y exámenes ahora con Quizwiz!

Consider the following program code, which does not work as intended. The intent of the code is to display the number of years it will take for a population to exceed 10,000. population ← INPUT() years ← 1 REPEAT UNTIL (population > 10000) { population ← population * 2 } DISPLAY years Which of the following changes would make the program run as intended? I. Initialize population to 0 before entering the loop II. Initialize population to 0 after entering the loop III. Insert the code years ← years + 1 within the loop

III only

Predict the output of the following code block scores ← [99, 67, 65, 78, 85] i ← 0 FOR EACH s IN scores { < MISSING STATEMENTS > } Which of the following replacements for < MISSING STATEMENTS > will result in the list of scores having all elements with values less than 70 removed. 1. IF (scores[s] < 70) { REMOVE(scores, s) } 2. IF (scores[i] < 70) { REMOVE(scores, i) } i ← i + 1 3. i ← i + 1 IF (scores[i] < 70) { REMOVE(scores, i) i ← i - 1 }

III only

Which of the following are advantages of using procedures? Select two answers. Reduced debugging time Faster run time Increased creative expression Reduced coding time

Reduced debugging time, Reduced coding time

A new bank plans to make customers convenience a priority by minimizing the amount of time a customer waits in line. The bank is considering two options: a single line where the customer at the front waits for the next available teller, or separate lines for each teller. The bank decides to use a computer simulation of these two options to determine the average wait time for customers. Which of the following is NOT true about the bank's plan?

The simulation will not produce usable results because actual customer data are not available.

A certain social media Web site allows users to post messages and to comment on other messages that have been posted. When a user posts a message, the message itself is considered data. In addition to the data, the site stores the following metadata. The time the message was posted The name of the user who posted the message The names of any users who commented on the message and the times the comments were made For which of the following goals would it be more useful to analyze the data instead of the metadata?

To determine the topics that many users are posting about

A search engine has a trend-tracking feature that provides information on how popular a search term is. The data can be filtered by geographic region, date, and category. Categories include arts and entertainment, computers and electronics, games, news, people and society, shopping, sports, and travel. Which of the following questions is LEAST likely to be answerable using the trends feature?

What is the cost of a certain electronics product?

The following program is intended to count how many matched there are in a list. The procedure does not work as intended. match ← "cheese" PROCEDURE CountMatch(match,list) { counter ← 0 FOR EACH item IN list { IF item = match { counter ← 1 } } return counter } For which of the following values of list will CountMatch NOT return the intended value?

["flour", "cheese", "milk", "cheese"] (bc of repeated cheese)

Trudy is writing a program to input student grades from a particular test. It will also use the variable count to keep track of the number of times a user enters the particular score of 85. Of the steps below, which should appear earliest in her pseudocode?

count <- 0

Suppose you have a hand of standard playing cards. Which of the following operations, performed by an algorithm, would most likely use both selection and iteration?

determine the number of cards with the suit equal to hearts

the j loop thingy

j mod 4 = 0

the k=10 loop thingy

k+4

Two lists, list1 and lists2, contain the names of books found in two different collections. A librarian wants to create newList, which will contain the names of all books found in either list, in alphabetical order, with duplicate entries removed. For example, if list1 contains ["Macbeth", "Frankenstein", "Jane Eyre"] and list2 contains ["Frankenstein", "Dracula", "Macbeth", "Hamlet"] then newList will contain ["Dracula", "Frankenstein", "Hamlet", "Jane Eyre", "Macbeth"] The following procedures are available to create newList.

newList ← Combine (list1, list2) newList ← Sort (newList) newList ← RemoveDuplicates (newList)

Consider the segment of code below: list ← [27, 44, 13, 16, 29, 32, 55] list1 ← [0] FOR EACH item IN list { IF (item MOD 2 = 0) { APPEND(list1, item) } } DISPLAY(list1) Which of the following represents the result of executing the program?

0, 44, 16, 32

Which of the following scenarios includes both selection and iteration? Select two answers.

1. A teacher selecting a male student from a class of 25 students with at least one male and one female student. 2. A teacher trying to find the tallest student in the class of 25 students by arranging the heights of the students in ascending order.

The program below prints report cards for Marymount High School. The procedure PrintRun(month, year) takes 30 minutes to run. All other program steps can be assumed to happen nearly instantaneously. Assume that todayMonth and todayYear are the current month and year. FOR EACH year IN [2017, 2018] { FOR EACH month IN ["January", "April", "July", "October"] { PrintRun (month, year) } } PrintRun (todayMonth, todayYear)

270 minutes

"N is not yet equal to 64" loop

6 times

41 mod 7 question

79 (bc outside of range)

As a computer science student, you are writing a program to help your administration search for a particular student from an unsorted list of all students in your school. Which of the following statement is true?

A linear search is more appropriate than a binary search because the list is not sorted.

Which of the following is LEAST likely to indicate a phishing attack?

An call from bank to confirm...

the one with the 2 programs

Both program I and program II display the correct sum.

Predict the output of the following code block scores ← [99, 67, 65, 78, 85] highScores ← [] FOR EACH s IN scores { < MISSING STATEMENTS > } Which of the following replacements for < MISSING STATEMENTS > will result in the list of highScores having all elements with values greater than or equal to 70? IF (s >= 70) { APPEND(highScores, s) } IF (scores >= 70) { APPEND(highScores, scores) } IF (s >= 70) { APPEND(highScores, scores) }

I only

the robot and gray square one

IF (CAN_MOVE (right)) { ROTATE_RIGHT () } IF (CAN_MOVE (left)) { ROTATE_LEFT () } MOVE_FORWARD()

A(n) ____ loop tests the condition at the bottom of the loop.

post-test

first/second/temp question

temp <-- first

the one with the 3 circles

xPos ← 3 yPos ← 3 REPEAT 3 TIMES { DrawCircle (xPos, yPos, 3) xPos ← xPos + 6 }


Conjuntos de estudio relacionados

sociology chapter 5 Separate and Together: Life in Groups

View Set

PrepU: Chapter 12: Nursing Management During Pregnancy

View Set

Chapter 5: Data & Knowledge Management

View Set

Unit 2 - Erythrocytes (Chapters 5-7)

View Set

ACT Prep (English) Practice Questions

View Set

McCurnin's Clinical Textbook for Veterinary Technicians Chapters 1-4

View Set

Chapter 32: Twenty-First-Century America, 1993-Present

View Set

Lesson 2: Explaining Threat Actors and Threat Intelligence

View Set