








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 series of questions and answers related to algorithm analysis, covering topics such as big-o notation, binary search, graph theory, and dynamic programming. It includes true/false questions, multiple-choice questions, and problems related to linear programming. The material is suitable for students studying computer science and algorithm design, providing a concise review of key concepts and problem-solving techniques. Useful for exam preparation and self-assessment, offering a quick reference to fundamental principles and common algorithms. It covers a range of topics, from basic algorithm properties to more advanced concepts like dynamic programming and linear programming, making it a valuable resource for students seeking to reinforce their understanding of algorithm analysis.
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)? - Correct answer-False 3^n + 12 - Correct answer-O(2^n) What is the Asymptotic complexity of a binary search given the code below and the following recursion equation: T(n) = T(n/2) + 1 // initially called with low = 0, high = N - 1 BinarySearch_Right(A[0..N-1], value, low, high) { // invariants: value >= A[i] for all i < low value < 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 execute if the value of n is 4? var M = A[ 0 ]; 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. - Correct answer-False Which of the following is NOT a property of logarithms? a.log(nm) = log n + log m b.log(n/m) = log n - log m c. log (n^r)= r log n d.log(b) n= log(n)b log(a)b - Correct answer-d True/False: An algorithm is a well-defined sequence of steps used to solve a well- defined problem in finite time. - Correct answer-True True/False: The running time of an algorithm is the number of instructions it executes when run on a particular instance. - Correct answer-True True/False: An algorithm is a well-defined sequence of steps used to solve a well- defined problem in an infinite number of steps. - Correct answer-False True/False: The backtracking algorithm treats the solution space as a graph and follows a path to conclusion to find a solution to a problem. The algorithm may 'backtrack' by reversing up to previous branches in a tree and try all branches to find the solution. - Correct answer-True The Backtracking algorithm implements what search? a.Depth First Search b.Sequential search c. Breadth First Search
True/False: A graph with edges that point in such a way that one could follow such directed edges and visit the same vertex again, as is illustrated in the following diagram is a graph that is said to have or be: a.Directed b.Cyclic or cycles c. Free tree d.Acyclic - Correct answer-b A process that is designed to visit every vertex in a graph is known as a: a.Graph traversal b.Graph search c. Binary search d.Enumeration - Correct answer-a In the following graph what do the circles represent? a.Edges b.Vertices c. Nodes d.Cycles - Correct answer-b What term best describes this graph? (graph with no arrows, just lines) a.Directed Graph b.Undirected Graph c. Tree d.Directed Acyclic Graph - Correct answer-b
What term best describes this graph? (graph with arrows, no lines) a.Directed Graph b.Undirected Graph c. Tree d.Directed Acyclic Graph - Correct answer-d What is the big-o complexity of the second line on the left? - 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.Breadth first search. b.Depth first search. c. A cycle-finding algorithm. d.A shortest-path algorithm. - Correct answer-d Breadth first search __________. a.Scans each incident node along with its children. b.Scans all incident edges before moving to other node. Correct c. Is same as backtracking. d.Scans all the nodes in random order. e.Scans all the nodes in pre-order manner. - Correct answer-b What will be the Big-Oh complexity to search a balanced binary tree?
b.Breadth first c. Back-tracking d.Bounding - Correct answer-b _____ is the time complexity of an algorithm that operates in linear time. The process time changes in the same ratio as the data size. - Correct answer-O(n) What is the big-o complexity of the green line? (third line to the right) - Correct answer-O(n log n) ______ is the time complexity of an algorithm that operates in exponential time. This means that process times doubles with the addition of each data element. - Correct answer-O(2^n) True/False: O(1) is the time complexity of an algorithm that operates in constant time. The process time required stays constant regardless of the data size. - Correct answer-True What is the Big-Oh complexity of the selection sort? - Correct answer-O(n^2) What is the big-o complexity of the purple line? (third line to the left) - Correct answer-O(n²) What will be the Big-Oh complexity of a linear search? - Correct answer-O(n) True/False: Dynamic Programming reduces asymptotic complexity by eliminating redundant computations. - Correct answer-True True/False: Recursive routines cannot be used in Dynamic Programming algorithms?
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.Memorization: answers to subproblems are remembered to avoid repeated computation of the same thing. d.Recursion: implemented as a recursive routine to reduce overhead and improve computational efficiency. - Correct answer-d True/False: In a dynamic programming algorithm, we can use a table to store results of sub-problems and then refer to this table to ensure that we don't recomputed those sub-problems. - Correct answerTrue True/False: Dynamic programming is a variation of the linear programming model in that it breaks the problem down into smaller problems that are solved using the simplex method? - Correct answer-False True/False: Dynamic programming is less complex asymptotically but is substantially more complex from a programming perspective? - Correct answer-False Linear programming problems can be solved using which of the following: a.Simplex method Correct b.Quick method c. Stochastic method d.None of these answers - Correct answer-a Consider: A farmer can plant up to 8 acres of land with wheat and barley. He can earn $5,000 for every acre he plants with wheat and $3,000 for every acre he plants with barley. His use of a necessary pesticide is limited by federal regulations to 10 gallons for his entire 8 acres. Wheat requires 2 gallons of pesticide for every acre
In a linear programming problem assuming the Simplex Method the following is known as: a.The Constraints Incorrect b.The Solution definition c. The Problem definition d.The Tableau - Correct answer-d In a linear programming problem, a statement such as max x1 + 6x2 represents: a.A constraint function b.The Objective function c. The maximization function Incorrect d.The feasible function - Correct answer-b True/False: Linear programming is used primarily to solve problems of optimization?
True/False: The Simplex method is important for computer programming, as the need for processing power is significantly lower when using it as opposed to other methods. - Correct answer-True 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 and desktops produced must both be greater than 0. 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 built to maximize the profits of the manufacturer and determine how much revenue will be generated. Please enter a numerical answer only; do not enter any letters or words. If the answer is a dollar amount, please enter in the following format: $#,### Ho - Correct answer- 150 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 and desktops produced must both be greater than 0. 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 built to maximize the profits of the manufacturer and determine how much revenue will be generated.
c. NP-Easy d.P - Correct answer-a True/False: A reduction is solving problem A using problem B where an algorithm for B exists (for example redefining an optimization problem as a search problem). - Correct answer-True True or False: Circuit Satisfiability is not a representation for a NP-hard problem as it can be solved in O(n2) time. - Correct answer-False The Class of P problems are (select the best answer): a.Problems that can all be solved quickly in O(n) time. b.Are not included in the set of NP problems. c. The set of problems that can be solved in polynomial time. d.All of these responses. - Correct answer-c True or False: NP-complete problems are a subset that is the intersection between NP problems and NPHard problems. - Correct answer-True True or False: The Cook-Levin Theorem states that Circuit satisfiability is NP- complete. - Correct answerTrue Which of the following is NOT an NP-Complete, Hard problem? a.Traveling Salesman Problem b.Knapsack c. Integer Linear Programming d.Minimum Spanning Tree - Correct answer-d Which of the following is NOT a P (polynomial), easy problem? - 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