k

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

A time stamp indicates the date and time that a measurement was taken. A data scientist has a list containing 10,000 time stamps, sorted in chronological order. Which of the following is closest to the maximum number of values that will need to be examined when performing a binary search for a value in the list?

15

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 , which returns the number of unique users who viewed videos of a given category in the past year. The 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.

5 hours

A sorted list of numbers contains 128 elements. Which of the following is closest to the maximum number of list elements that can be examined when performing a binary search for a value in the list?

8

A computer scientist is analyzing four different algorithms used to sort a list. The table below shows the number of steps each algorithm took to sort lists of different sizes.

Algorithm A, Algorithm D

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.

Both code segments display the correct average, but code segment I requires more arithmetic operations than code segment II.

Which of the following best compares the values displayed by programs A and B? REPEAT UNTIL I>10 REPEAT UNTIL i ≥10

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

Which of the following best compares the values displayed by programs A and B? REPEAT UNTIL I>10 REPEAT UNTIL i>10

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

Which of the following best explains how algorithms that run on a computer can be used to solve problems?

Some problems cannot be solved by an algorithm.

The figure below shows four grids, each containing a robot represented as a triangle. The robot cannot move to a black square or move beyond the edge of the grid.

Step 1: Keep moving forward, one square at a time, until the square to the right of the robot is no longer black. Step 2: Turn right and move one square forward. Step 3: Repeat steps 1 and 2 three more times.

A graphic artist uses a program to draw geometric shapes in a given pattern. The program uses an algorithm that draws the shapes based on input from the artist. The table shows the approximate number of steps the algorithm takes to draw different numbers of shapes. Number of Shapes Drawn Number of Steps 4 17 5 24 6 35 7 50 Based on the values in the table, which of the following best characterizes the algorithm for drawing n shapes, where n is a very large number?

The algorithm runs in a reasonable amount of time because it will use approximately n2 steps to draw n shapes.

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 ?

The algorithm runs in reasonable time.

Which of the following best describes the ability of parallel computing solutions to improve efficiency?

The efficiency of a solution that can be broken down into parallel portions is still limited by a sequential portion.

A large number of genetic codes are stored as binary values in a list. Which one of the following conditions must be true in order for a researcher to obtain the correct result when using a binary search algorithm to determine if a given genetic code is in the list?

The list must be sorted based on the genetic code values.

The list listOne is a sorted list of numbers that contains 700 elements. The list listTwo is a sorted list of numbers that contains 900 elements. Let x represent the maximum number of list elements that will need to be examined when performing a binary search for a value in listOne, and let y represent the maximum number of list elements that will need to be examined when performing a binary search for a value in listTwo. Which of the following statements about x and y is true?

The value of x is approximately equal to the value of y.

Which of the following best explains the ability to solve problems algorithmically?

There exist some problems that cannot be solved algorithmically using any computer.

Which of the following best explains why it is not possible to use computers to solve every problem?

There exist some problems that cannot be solved using any algorithm.

The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the center square and facing toward the top of the grid. The following code segment is used to move the robot in the grid.

count ←← 0 REPEAT 4 TIMES { count ←← count + 1 REPEAT count TIMES { MOVE_FORWARD() } ROTATE_LEFT() }

In the following code segment, assume that x and y have been assigned integer values. sum ←← 0 REPEAT x TIMES { REPEAT y TIMES { sum ←← sum + 1 } } At the end of which of the following code segments is the value of sum the same as the value of sum at the end of the preceding code segment?

sum ←← 0 z ←← x * y REPEAT z TIMES { sum ←← sum + 1 }

A certain computer has two identical processors that are able to run in parallel. The table below indicates the amount of time it takes each processor to execute each of two processes. Assume that neither process is dependent on the other.

30 seconds

A company delivers packages by truck and would like to minimize the length of the route that each driver must travel in order to reach n delivery locations. The company is considering two different algorithms for determining delivery routes. Algorithm I: Generate all possible routes, compute their lengths, and then select the shortest possible route. This algorithm does not run in reasonable time. Algorithm II: Starting from an arbitrary delivery location, find the nearest unvisited delivery location. Continue creating the route by selecting the nearest unvisited location until all locations have been visited. This algorithm does not guarantee the shortest possible route and runs in time proportional to n2 Which of the following best categorizes algorithm II?

Algorithm II uses a heuristic approach to provide an approximate solution in reasonable time.

For which of the following situations would it be best to use a heuristic in order to find a solution that runs in a reasonable amount of time?

Finding the fastest route that visits every location among n locations, which requires n! possible routes be examined.

Consider the following algorithms. Each algorithm operates on a list containing n elements, where n is a very large integer. I. An algorithm that accesses each element in the list twice II. An algorithm that accesses each element in the list n times An algorithm that accesses only the first 10 elements in the list, regardless of the size of the list Which of the algorithms run in reasonable time?

I, II, and III

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

I, II, and III

Consider the following code segment with an integer variable num. IF(num > 0) { DISPLAY("positive") } IF(num < 0) { DISPLAY("negative") } IF(num = 0) { DISPLAY("zero") } Which of the following code segments is equivalent to the code segment above?

IF(num < 0) { DISPLAY("negative") } ELSE { IF(num = 0) { DISPLAY("zero") } ELSE { DISPLAY("positive") } }

Three different numbers need to be placed in order from least to greatest. For example, if the numbers are ordered 9, 16, 4, they should be reordered as 4, 9, 16. Which of the following algorithms can be used to place any three numbers in the correct order?

If the first number is greater than the middle number, swap them. Then, if the middle number is greater than the last number, swap them. Then, if the first number is greater than the middle number, swap them.

The following question uses a robot in a grid of squares. The robot is represented as a triangle, which is initially facing toward the top of the grid. The following code segment moves the robot around the grid. Assume that n is a positive integer. Line 1: count ←← 0 Line 2: REPEAT n TIMES Line 3: { Line 4: REPEAT 2 TIMES Line 5: { Line 6: MOVE_FORWARD() Line 7: } Line 8: ROTATE_RIGHT() Line 9: } Consider the goal of modifying the code segment to count the number of squares the robot visits before execution terminates. Which of the following modifications can be made to the code segment to correctly count the number of squares the robot moves to?

Inserting the statement count ←← count + 1 between line 6 and line 7

A certain computer has two identical processors that are able to run in parallel. The following table indicates the amount of time it takes to execute each of four processes on a single processor. Assume that none of the processes is dependent on any of the other processes. Process Execution Time either Processor P 30second Q 10second R 20second S 15second

Running processes P and Q on one processor and processes R and S on the other processor

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?

The elements of the list are not sorted.

The procedure BinarySearch (numList, target) correctly implements a binary search algorithm on the list of numbers numList. The procedure returns an index where target occurs in numList, or -1 if target does not occur in numList. Which of the following conditions must be met in order for the procedure to work as intended?

The values in numList must be in sorted order.

A team of programmers is designing software. One portion of the project presents a problem for which there is not an obvious solution. After some research, the team determines that the problem is undecidable. Which of the following best explains the consequence of the problem being undecidable?

There is no possible algorithm that can be used to solve all instances of the problem.

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?

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

A sorted list of numbers contains 200 elements. Which of the following is closest to the maximum number of list elements that will need to be examined when performing a binary search for a particular value in the list?

8

Which of the following best describes a challenge involved in using a parallel computing solution?

A parallel computing solution may not be appropriate for an algorithm in which each step requires the output from the preceding step.

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?

It is not possible to create an algorithm that will solve the problem for all programs and inputs.

The following grid contains a robot represented as a triangle, which is initially in the bottom-left square of the grid and facing the top of the grid. The robot can move into a white or a gray square but cannot move into a black region. The following code segment implements an algorithm that moves the robot from its initial position to the gray square and facing the top of the grid. When the robot reaches the gray square, it turns around and faces the bottom of the grid. Which of the following changes, if any, should be made to the code segment to move the robot back to its original position in the bottom-left square of the grid and facing toward the bottom of the grid?

No change is needed; the algorithm is correct as is.

A computer has two processors that are able to run in parallel. The table below indicates the amount of time it takes either processor to execute four different processes. Assume that none of the processes is dependent on any of the other processes. Process Execution Time W 20 seconds X 30 seconds Y 45 seconds Z 50 seconds

Processes W and Z should be assigned to one processor, and processes X and Y should be assigned to the other processor.

A student wants to determine whether a certain problem is undecidable. Which of the following will demonstrate that the problem is undecidable?

Show that for one instance of the problem, no algorithm can be written that is capable of providing a correct yes-or-no answer.


Set pelajaran terkait

History 1300 Final Multiple Choice

View Set

Chapter 1 Biopsychology as a Neuroscience:

View Set

Forms in W-2 Series Line-By-Line

View Set

Nature of the Church Erickson ch. 50 [49] / McCune 49-52

View Set

Medical-Surgical Nursing, 13th Edition - Exam 2 Study Questions

View Set