Algorithms
Algorithms 2
Coding, Parameters, Returns
Program Design / Libraries
Potpourri
100


Which of the following is true of algorithms? 

a) Algorithms may have an infinite set of instructions 

b) Algorithms must be expressed using a programming language 

c) Every algorithm can be constructed using combinations of sequencing, selection, and iteration

d) Every problem can be solved with an algorithm 


 C.   Every algorithm can be constructed using combinations of sequencing, selection, and iteration 

100

A software company used to run an algorithm sequentially on one server. As more users start using their app, the company decided to rewrite the program to be parallel. It is now run on four separate servers instead of one Thanks to the use of a parallel algorithm, the same process that used to take 40 minutes to run now only requires 20 minutes.

The company is considering purchasing additional computers to decrease the time the program runs even further. Which of the following best describes the impacts of running the parallel algorithm on an even larger number of computers

A.   The algorithm will likely require more time since it is now being run sequentially on more computers.

B.   The algorithm will likely require the same amount of time to run because it is processing the same amount of data

C.   The algorithm will likely require less time to run though the improvements in efficiency will not be as significant as before.

D.   The algorithm is unlikely to still run since parallel algorithms are not designed to scale to additional computers 

C.   The algorithm will likely require less time to run though the improvements in efficiency will not be as significant as before. 

100

Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment.

A.   num % 2 == 0

B.   num % 0 == 2

C.   num % 1 == 0

D.   num % 1 == 2 


A.  num % 2 == 0 

100

Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems.

 A.   procedural abstraction

 B.   API

 C.   parameter

 D.   library 

A.   procedural abstraction 

100

Which of the following is NOT true of how computers represent complex information?

 A.   Computing devices use patterns of bits to represent complex information

 B.   Abstraction helps represent complex information by surfacing complexity that might otherwise be hidden

 C.   Depending on context the same sequence of bits may represent different types of information

 D.   Common abstractions that are represented by computing devices include numbers, characters, and color. 

B.   Abstraction helps represent complex information by surfacing complexity that might otherwise be hidden 

200

A town government is designing a new bus system and are deciding where to put the different bus stops. They want to pick the collection of locations that minimizes the distance anyone needs to walk in order to get to at least one bus stop. What term best defines the kind of problem?

A.   A decision problem 

B.   An optimization problem 

C.   An undecidable problem 

D.   An efficiency problem   

B.  An optimization problem 

200

Which of the following are benefits of parallel and distributed computing?

I. Distributed computing improves the speed at which an individual computer executes a program

II. Parallel computing scales more effectively than sequential computing

III. Distributed computing allows larger problems to be solved quicker

A.   I only

B.   I and II

C.   II and III

D.   I, II, and III 

C.  II and III 

200

What will be printed to the console after this program runs?

 

A.   [2, 5, 3, 1, 6]

B.   [0, 3, 6, -1, 9]

C.   [-1, 2, 6, -2, 8]

D.   [5, 2, 6, 3, 9] 

B.  [0, 3, 6, -1, 9] 

200

What is one of the benefits of using a library in a program?

 A.   simplifies creating a complex program

 B.   increases development time

 C.   removes all testing

 D.   reduces abstractions in the program 

 A.   simplifies creating a complex program

200

Emilee is watching an online video. The video is being sent to her laptop by a server over the Internet which splits the video into packets and sends them in the order they appear in the video. Which of the following is true about how the packets will arrive at her computer?

 A.   The packets will always be received in the order that they were sent

 B.   Either every packet will reach her computer or none of them will.

 C.   Packets that arrive out of order will be sent back to the server.

 D.   The packets may arrive out of order 

D.   The packets may arrive out of order

300


A group of students writes their names and unique student ID numbers on sheets of paper. The sheets are then randomly placed in a stack.

Their teacher is looking to see if a specific ID number is included in the stack. Which of the following best describes whether their teacher should use a linear or a binary search?

A.   The teacher could use either type of search though the linear search is likely to be faster 

B.   The teacher could use either type of search though the binary search is likely to be faster 

C.   Neither type of search will work since the data is numeric

D.   Only the linear search will work since the data has not been sorted  

D.   Only the linear search will work since the data has not been sorted 

300

A sequential algorithm is broken into three stages

Sequential Algorithm Time

  • Download stage: 1 minute
  • Sorting stage: 6 minutes
  • Upload stage: 1 minute

A parallel version of the algorithm completes the sorting stage in parallel leading to a new set of times

Parallel Algorithm Time

  • Download stage: 1 minute
  • Sorting stage: 2 minutes
  • Upload stage: 1 minute

What is the speedup of the parallel solution?

A.   6 minutes

B.   4 minutes

C.   2

D.   3 

C.  2 

300

Which function calls would provide the most helpful test of this function?

Remember: With tests, you are attempting to figure out all the possible ways the function could be broken.


A.
      findMin(-1, 0)
     findMin(2,4)
      findMin(5,10)
B.
      findMin(5,3)
     findMin(7,2)
      findMin(5,1)
C.
     findMin(1,1)
      findMin(-2,2)
      findMin(0,3)
D.
     findMin(-1,1)
     findMin(1,-1)
      findMin(1,1) 
D.
     findMin(-1,1)
     findMin(1,-1)
      findMin(1,1) 
300

Dividing a program into separate subprograms (such as libraries) is known as:

 A.   modularity

 B.   iteration

 C.   API

 D.   documentation 

A.   modularity 

300

In which of the following situations would parallel systems MOST likely be used to help analyze data?

 A.   Data analysis involving two or more columns of data

 B.   Data analysis involving both string and numeric data

 C.   Data analysis involving large datasets

 D.   Data analysis that could result in two or more different types of visualizations 


C.   Data analysis involving large datasets

400

A computer is performing a binary search on the sorted list of 7 numbers below. What is the maximum number of iterations needed to find the item?

[1, 5, 20, 50, 51, 80, 99]

 A.   1

 B.   3

 C.   6

 D.   7 

B.  3 

400

A school is creating class schedules for its students. The students submit their requested courses and then a program will be designed to find the optimal schedule for all students.

The school has determined that finding the absolute best schedule cannot be solved in a reasonable time. Instead they have decided to use a simpler algorithm that produces a good but non-optimal schedule in a more reasonable amount of time.

Which principle does this decision best demonstrate?

A.   Unreasonable algorithms may sometimes also be undecidable 

B.   Heuristics can be used to solve some problems for which no reasonable algorithm exists 

C.   Two algorithms that solve the same problem must also have the same efficiency 

D.   Approximate solutions are often identical to optimal solutions

B.  Heuristics can be used to solve some problems for which no reasonable algorithm exists 

400

This function checks if a character is a vowel. If it is, it returns true. Otherwise, it returns false.

Where should return false; be written in the code?

 A.   OPTION A

 B.   OPTION B

 C.   OPTION C

 D.   OPTION D 

C.  OPTION C 

400

Which call of the function correctly follows the instructions laid out in the API? 


 A.   moveElement("button1", 2, 23);

 B.   moveElement("button1", "left", "thirty");

 C.   moveElement("button1", 30, "two");

 D.   moveElement("button1", "down", 25); 

D.   moveElement("button1", "down", 25); 

400

A restaurant is interested in learning about the food preferences of people living nearby to the restaurant and intends to use survey data to help decide which new items to add to the menu. Which of the following is LEAST likely to be part of the process used to analyze the data?


 A.   Cleaning a data visualization to remove unwanted patterns

 B.   Iteratively creating visualizations to ask and answer new questions

 C.   Cleaning data to remove inconsistencies

 D.   Filtering the data to look at the responses from only certain groups

A.   Cleaning a data visualization to remove unwanted patterns

500

The algorithm below is used to find the largest element in a list of numbers.

By modifying one of the lines in the program it is possible to make the algorithm find the SMALLEST element. Which line would need to be modified and how?

A.   Line 01 becomes target <- list[2] 

B.   Line 04 becomes IF (num < target)  

C.   Line 04 becomes IF (num = target) 

D.   Line 01 becomes list[0] <- target

B.   Line 04 becomes IF (num < target) 

500

The API (Application Program Interface) ...

A.   is a list of programs that can use a library

B.   tells the programmer when they can use the library functions

C.   is documentation that specifies how to use the functions

D.   helps the programmer debug their functions

C.   is documentation that specifies how to use the functions

500

An Internet Service Provider (ISP) is a company that builds the routers and wired connections that allow individuals to access the Internet.   An ISP is considering adding additional redundant connections to its network. Which of the following best describes why the company would choose to do so?

A.  It costs less to design a network that is redundant

B.  The protocols of the Internet only work on networks that are redundant

C.  Redundant networks are more reliable

D.  Adding additional connections reduces the fault-tolerance of the network

C.  Redundant networks are more reliable

M
e
n
u