








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A midterm exam on algorithm analysis, focusing on key concepts such as big-o notation, asymptotic complexity, and graph theory. It includes true/false questions, multiple-choice questions, and problems related to algorithm performance and data structures. The exam covers topics like binary search, dynamic programming, linear programming, and graph traversal, providing a comprehensive assessment of understanding in algorithm analysis. It is useful for students to test their knowledge and understanding of algorithm analysis concepts, and to prepare for exams. A series of questions and answers related to algorithm analysis, covering topics such as time complexity, graph theory, and linear programming. It serves as a study aid for students preparing for exams or seeking to reinforce their understanding of these concepts.
Typology: Exams
1 / 14
This page cannot be seen from the preview
Don't miss anything!









True/False: Is 2^(n+1) = O(2^n)? 3^n + 12 - Correct answer-O(2^n) - Correct answer-False What is the Asymptotic complexity of a binary search given the code below and the following recursion T(n) = T(n/2) + 1 equation:
// invariants:^ // initially called with low = 0, high = N^ BinarySearch_Right(A[0..N value >= A[i] for all i < low value <-1], value, low, high) {^ -^1 A[i] for all i > high if (high < low) return low mid = (low + high) / 2 if (A[mid] > value) return BinarySearch_Right(A, value, low, mid-1) else return BinarySearch_Right(A, value, mid+1, high) } - Correct answer-O(lg * n) Given the following algorithm, what is the number of fundamental instructions that this routine will var M = A[ 0 ]; execute if the value of n is 4? for ( var i = 0; i < n; ++i ) { if ( A[ i ] >= M ) { M = A[ i ];
}} - Correct answer-4+2n True/False: A Boolean variable can take on only 1 value. Which of the following is NOT a property of logarithms? - Correct answer-False a. b. c. log(nm) = log n + log mlog(n/m) = log nlog (n^r)= r log n - log m True/False: An algorithm is a well^ d. finite time.^ log(b) n= log(n)b - Correct answer^ log(a)b^ - -^ Correct answerTrue-defined sequence of steps used to solve a well-d -defined problem in True/False: The running time of an algorithm is the number of instructions it executes True/False: An algorithm is a well particular instance. - Correct answer-defined sequence of steps used to solve a well-True -defined problem in an when run on a True/False: The backtracking algorithm t^ infinite number of steps. conclusion to find a solution to a problem. The algorithm may 'backtrack' by reversing up to previous^ -^ Correct answerreats the solution space as a graph and follows a path to-False The Backt^ branches in a tree and try all branches to find the solution.racking algorithm implements what search?^ -^ Correct answer-True a. b. c. Depth First SearchSequential searchBreadth First Search
a. b. c. DirectedCyclic or cyclesFree tree A process that is designed to visit every vertex in a graph is known as a:^ d.^ Acyclic^ -^ Correct answer-b a. b. c. Graph traversalGraph searchBinary search In the following graph what do the circles represent?^ d.^ Enumeration^ -^ Correct answer-a a. b. c. EdgesVertiNodesces What term best describes this graph?^ d.^ Cycles^ -^ Correct answer-b (graph with no arrows, just lines) a. b. Directed GraphUndirected Graph c. d. TreeDirected Acyclic Graph - Correct answer-b
What term best describes this graph? (graph with arrows, no lines) a. b. c. Directed GraphUndirected GraphTree What is the big^ d.^ Directed Acyclic Graph-o complexity of the second line on the left?^ -^ Correct answer-d - Correct answer-O(2^n) Suppose you have a directed graph representing all the flights that an airline flies and the flying times for each connection. What algorithm might be used to find the best sequence of connections from one city to another to minimize the overall time of the flight? a. b. c. Breadth first search.Depth first search.A cycle-finding algorithm. Breadth first search __________.^ d.^ A shortest-path algorithm.^ -^ Correct answer-d a. b. c. Scans each incident node along with its children.Scans all incident edges beforeIs same as backtracking. moving to other node. Correct d. e. Scans all the nodes in random order.Scans all the nodes in pre-order manner. - Correct answer-b What will be the Big-Oh complexity to search a balanced binary tree?
a. b. c. Depth FirstBreadth firstBack-tracking _____ is the time complexity of an^ d. the same ratio as the data size.^ Bounding^ -^ Correct answer-b - Correct answer algorithm that operates in linear time. The process time changes in-O(n) What is the big ______ is the time comple times doubles with the addition of each data element.-o complexity of the green line? (third line to the right)xity of an algorithm that operates in exponential time. This means that process - Correct answer - Correct answer-O(2^n) -O(n log n) True/False: O(1) is the time complexity of an algorithm that operates in constant time. The pro What is the Big required stays constant regardless of the data size.-Oh complexity of the selection sort? - Correct answer- Correct answer-True-O(n^2) cess time What is the big What will be the Big-o complexity of the purple line? (third line to the left)-Oh complexity of a linear search? - Correct answer - Correct answ-O(n) er-O(n²) True/False: Dynamic Programming reduces asymptotic complexity by eliminating redundant True/False: Recursive routines cannot be used in Dynamic Programming algorithms? computations. - Correct answer-True - Correct Which of the following is NOT one of the main principles of dynamic programming algorithms?^ answerTrue a. Optimal substructure: optimal solutions to problems are built from optimal solutions to subproblems.
b. "Shop around": to determine the best op tion, try them all and select the best one. Do not employ heuristics. c. d. Memorization: answers to subproblems are remembered to avoid repeated computation of the same tRecursion: implemented as a recursive routine to reduce overhead and improve computationalhing. True/False: In a dynamic programming algorithm, we can use a table to store results of sub then refer to this table to ensure that we don't recomputed those sub^ efficiency.^ -^ Correct answer-d -problems. - Correct answer-problems andTrue True/False: Dynamic programming is a variation o True/False: Dynamic programming is less complex asymptotically but is substantially more complex fro problem down into smaller problems that are solved using the simplex method?f the linear programming model in that it breaks the - Correct answer-Falsem Linear programming problems can be solved using which of the following:^ a programming perspective?^ -^ Correct answer-False a. b. c. Simplex method CorrectQuick methodStochastic method Consider: A farmer can plant up to 8 acres of land with wheat and barley. He can earn $5,000 for every^ d. acre he plants with wheat and $3,000 for every acre he plants with barley. His use of a necessary^ None of these answers^ -^ Correct answer-a pesticide is limited by federal regulations to 10 gallo pesticide for every acre planted and barley requires just 1 gallon per acre. Problem: What is the maximum profit he can make? Assumptions: let x = the number of acres of wheat and let y = the number of acres of barley. Which of the following is a valid constraint for this problem?ns for his entire 8 acres. Wheat requires 2 gallons of
a. b. c. The Constraints IncorrectThe Solution definitionThe Problem definition In a linear programming problem, a statement such as max x1 + 6x2 represents:^ d.^ The Tableau^ -^ Correct answer-d a. b. c. A constraint functionThe Objective functionThe maximization function Incorrect True/False: Linear programming is used primarily to solve problems of optimization?^ d. answer^ The feasible functionTrue^ -^ Correct answer-b - Correct True/False: In linear programming, either the constraints or the op True/False: In a linear programming problem there can be no more than 3 constraints: functions. - Correct answer-False timization criteria must be linear - Correct True/False: In linear programming a constraint must be represented as a False^ answerFalse inequality. - Correct answer- True/False: Linear programming is an excellent approach for optimization problems where the objective True/False: The Simplex method is important for c function graphs as a curvilinear line. - Correct answeromputer programming, as the need for processing-False For the following questions, please read this problem statement:^ power is significantly lower when using it as opposed to other methods.^ -^ Correct answer-True
A computer manufacturer must determine what 8 Memory modules. A desktop computer requires 1 CPU and 4 Memory modules. Each server is sold for $1850 and each desktop is sold for $925. The manufacturer must produce a quantity of both units to kee than 0.p both lines in production so the quantity of servers and desktops produced must both be greater product mix to produce. A server requires 4 CPU's and The manufacturer can only get a supply of 1250 CPU's and 3800 memory modules due to shortages in the supply chain. Using the Simplex algorithm, dete should be built to maximize the profits of the manufacturer and determine how much revenue will be generated. rmine the number of servers and desktops that Please enter a numerical answer only; do not enter any letters or words. If the answer is a dolla Ho please enter in the following format: $#,### - Correct answer- 150 r amount, For the following questions, please read this problem statement: A computer manufacturer must determine what product mix to produce. A server requires 4 CPU's and 8 Memory modules. A desktop computer requires 1 CPU and 4 Memory modules. Each server is sold for $1850 and each desktop is sold for $925. The manufacturer must produce a quantity of both units to keep both lines in production so the quantity of servers an than 0. d desktops produced must both be greater The manufacturer can only get a supply of 1250 CPU's and 3800 memory modules due to shortages in the supply chain. Using the Simplex algorithm, determine the number of servers and desktops that should be generated. built to maximize the profits of the manufacturer and determine how much revenue will be Please enter a numerical answer only; do not enter any letters or words. If the answer is a dollar amount, Ho please enter in the following format: $#,### - Correct answer- 650
True or False: Circuit Satisfiability is not a representation for a NP The Class of P problems are (select the best answer): O(n2) time. - Correct answer-False -hard problem as it can be solved in a. b. c. Problems that can all be solved quickly in O(n) time.Are not included in the set of NP problems.The set of problems that can be solved in polynomial time. True or False: NP^ d. NPHard problems.^ All of these responses.-complete problems are a subset that is the intersection between NP problems and - Correct answer^ -^ Correct answer-True -c True or False: The Cook Which of the following is NOT an NP answerTrue -Levin Theorem states that Circuit satisfiability is NP-Complete, Hard problem? -complete. - Correct a. b. c. Traveling Salesman ProblemKnapsackInteger Linear Programming Which of the following is NOT a P (polynomial), easy problem?^ d.^ Minimum Spanning Tree^ -^ Correct answer-d - Correct answer-c True or False: All P problems are included in the set of problems that are considered to be NP (nondeterministic polynomial). - Correct answer-True
The Knapsack, Minimum Spanning Tree, Shortest Path, and Traveling Salesperson are all what kind of problem from an algorithms perspective? - Correct answer-Search