Midterm

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What does RAM stand for? A. Random Access memory B. Rapid Access Movement C. Answer Random Access Machine D. Real Action Mark-up

A

Linear probing is easy to implement, but it suffers from a problem known as A. Overflowing B. Fill up C. secondary clustering D. primary clustering

D

Quick sort, like merge sort, applies the A. Iterative paradigm B. Recursion paradigm C. Greedy paradigm D. Divide-and-conquer paradigm

D

SEARCH, MINIMUM, MAXIMUM, SUCCESSOR, and PREDECESSOR operations on red-black trees takes A. O(h) B. O(lg h) C. O(lg hn) D. O(lg n)

D

The RAM model operates by the following principles: 1. Basic logical or arithmetic operations (+, *, =, if, call) are considered to be simple operations that take one time step. 2. Loops and subroutines are complex operations composed of multiple time steps. 3. All memory access takes exactly one time step. How many of the above statements are correct? A. 1 & 2 are correct B. None are correct C. 2 & 3 are correct D. All are correct

D

The insertion sort has a worst-case running time of A. "theta of log n " B. "theta of n-cubed" C. "theta of n" D. "theta of n-squared"

D

The worst-case running time of an algorithm A. is often very bad compared to "average case" B. gives us an lower bound on the running time for any input C. does not occur often D. gives us an upper bound on the running time for any input

D

What is NOT the property of a Greedy Algorithm ? A. Overlapping sub problems B. Greedy Choice C. Optimal Substructure D. Non Overlapping sub problems

D

T&F: A heap can be constructed from an unordered array of numbers in linear worst-case time.

False

T&F: A heap with n elements can be converted into a binary search tree in O(n) time.

False

T&F: Given a graph G = (V, E) with cost on edges and a set S ⊆V , let (u; v) be an edge such that (u; v) is the minimum cost edge between any vertex in S and any vertex in V - S. Then, the minimum spanning tree of G must include the edge (u, v). (You may assume the costs on all edges are distinct, if needed.)

False

T&F: In an undirected graph, self-loops are possible.

False

T&F: Prim's algorithm executed on a planar graph will perform best when the priority queue is implemented using an array.

False

T/F: A heap with n elements can be converted into a binary search tree in O(n) time.

False

T/F: Insertion in a binary search tree is "commutative". That is, inserting x and then y into a binary search tree leaves the same tree as inserting y and then x.

False

T/F: The sub-tree of the root of a red-black tree is always itself a red-black tree (as per standard definition).

False

Select from the following methods which can be used to solve the longest common subsequence problem? 1. Recursion 2. Dynamic programming 3. Both recursion and dynamic programming 4. None of the mentioned A. 3 B. 1 C. 4 D. 2

A

The following paradigm can be used to find the solution of the problem in minimum time: Given a set of non-negative integer, and a value K, determine if there is a subset of the given set with sum equal to K: A. Dynamic Programming B. Divide and Conquer C. Greedy Algorithm D. Branch and Bound

A

The insertion sort has a worst-case running time of A. "theta of n-squared" B. "theta of n" C. "theta of n-cubed" D. "theta of log n "

A

The time required to compute the hash value h(k) is A. O(1) B. O(n) C. O(lg n )

A

The worst-case running time of an algorithm A. gives us an upper bound on the running time for any input B. is often very bad compared to "average case" C. does not occur often D. gives us an lower bound on the running time for any input

A

Unlike dynamic programming, which solves the subproblems before making the first choice, a greedy algorithm makes its first choice _______________________. A. before solving any subproblems B. while solving any subproblems C. after solving any subproblems

A

We say that an edge (u,v) ϵ E crosses the cut (S, V - S ) if one of its endpoints is in S and the other is in A. V - S B. E C. S D. V + S

A

What are the two equivalent ways to implement a dynamic-programming approach ? 1.top-down with memoization 2.bottom-up method 3.bottom-down method 4.top-up with memoization A. 1 & 2 B. 3 & 4 C. 1 & 4 D. 2 & 3

A

Which of the following statements about NP-Hardness are correct? 1. Some NP-hard decision problems can be verified in Polynomial time. 2.The hardest NP problems are called NP-hard problems. 3.Some of the co-NP problems can also be NP-hard as long as they are reducible from other NP problems. 4. A problem is NP-hard if an algorithm for solving it can be translated into one for solving any NP-problem, i.e., P=NP.

1, 4

A ________________ of a connected graph is a minimal set of edges whose removal separate the graph into two components. A. cut B. light edge C. min set

A

A binary tree is composed of three disjoint sets of nodes : A. a root node,left subtree , right subtree B. left subtree, right subtree, bottom subtree

A

A greedy strategy usually progresses in a A. top-down fashion B. None of the above C. bottom up fashion

A

A red-black tree with n internal nodes has height at most A. 2 (lg n +1) B. 2 (lg n-1) C. 2 ( n+1) D. 2 (lg n )

A

Consider the following lists of partially sorted numbers. The double bars represent the sort marker. How many comparisons and swaps are needed to sort the next number. [1 3 4 5 8 9 || 2] A. 6 comparisons, 5 swaps B. 5 comparisons, 4 swaps C. 5 comparisons, 6 swaps D. 4 comparisons, 5 swaps

A

Consider the strings "PQRSTPQRS" and "PRATPBRQRPS". What is the length of the longest common subsequence? 1. 9 2. 8 3. 7 4. 6 A. 7 B. 8 C. 9 D. 6

A

Dynamic programming approach is used when : 1. It provides optimal solution 2. The solution has optimal substructure 3. The given problem can be reduced to the 3-SAT problem 4. It's faster than Greedy A. 2 B. 1 C. 3 D. 4

A

Dynamic programming is typically applied to A. Optimization problems B. Non optimization problems C. Any Problem D. NP problem

A

Dynamic programming thus uses additional memory to save computation time; it serves an example of a A. time-memory trade-off B. time saving C. memory saving D. time-space trade-off

A

Insertion Sort works __________________ . A. in place B. out of place

A

Is a tree with all black nodes a red-black tree? A. Yes [The tree has to be a perfect binary tree ] B. No, its not.

A

LCS for input Sequences "ABCDGH" and "AEDFHR" is A. "ADH" of length 3 B. "ADR" of length 3 C. "ADFH" of length 4 D. "ABH" of length 3

A

LCS for input Sequences "AGGTAB" and "GXTXAYB" is A. GTAB B. GTA C. GAB D. GTAYB

A

MST Algorithms works on which of the following type(s) of graph: A. weighted ,connected, undirected B. weighted,disconnected, directed C. weighted,disconnected, undirected D.weighted,connected,directed

A

On an input array of n numbers ,the quicksort algorithm has a worst-case running time of A. theta (n^2) B. theta (log n) C. theta (n) D. theta (n^3)

A

Procedure LCS-LENGTH takes two sequences X =<x1, x2,....,xm> andY =<y1,y2,... ,yk> as inputs.It stores the c[i, j] values in a table c[0 .. m, 0 .. n], and it computes the entries in A. row-major order B. column-major order C. no particular order D. None of the above

A

Select all that is true: A hash function should have which properties? a.Uniform distribution. b. Speedy computation. c. The range is a subset of the integers. d. Equivalent objects produce equal hash codes. A. All of the mentioned B. None C. A, B, C D. A and B

A

What do you mean by "Programming" in the context of Dynamic Programming? A. A tabular method B. Writing code C. Writing java code

A

What is the special property of red-black trees and what root should always be? A. a color which is either red or black and root should always be black color only B. a color which is only black C. a color which is either green or black D. pointer to next node and root should always be black color only

A

What is the time complexity of the brute force algorithm used to find the longest common subsequence? 1. O(n) 2. O(n2) 3. O(n3) 4. O(2n) A. 4 B. 1 C. 2 D. 3

A

When developing a dynamic-programming algorithm, we follow a sequence ofsteps, Choose the correct ones from below: 1. Characterize the structure of an non optimal solution. 2. Recursively define the value of an optimal solution. 3. Compute the value of an optimal solution, typically in a bottom-down fashion. 4. Construct an optimal solution from computed information. A. 2 & 4 B. 1 & 2 C. 1 & 3 D. 3 & 4

A

Which approach cannot be used to solve the 0-1 Knapsack problem? A. Greedy strategy B. Dynamic programming C. Both

A

Which of the following is a self-adjusting or self-balancing Binary Search Tree? A. All of the above B. AVL Tree C. None of the above D. Red Black Tree

A

Which of the following operations are used by Red-Black trees to maintain balance during insertion/deletion? a) Recoloring of nodes b) Rotation (Left and Right) A. Both a and b B. Neither a and b C. Only b D. Only a

A

An edge is a light edge satisfying a given property if its weight is the A. addition of any edge satisfying the property B. minimum of any edge satisfying the property C. subtraction of any edge satisfying the property D. maximum of any edge satisfying the property

B

An undirected graph G has n nodes. Its adjacency matrix is given by an n × n square matrix whose (i) diagonal elements are 0's and (ii) non-diagonal elements are 1's. which one of the following is TRUE? A. Graph G has a unique MST of cost n-1 B. Graph G has multiple distinct MSTs, each of cost n-1 C. Graph G has no minimum spanning tree (MST) D. Graph G has multiple spanning trees of different costs

B

Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry Wij in the matrix W below is the weight of the edge {i, j}. What is the minimum possible weight of a spanning tree T in this graph such that vertex 0 is a leaf node in the tree T? A. 7 B. 10 C. 8 D. 9

B

For the problem of multiplying two integers what will best measure of the input size? A. Number of items in the input B. Total number of bits needed to represent the input in binary

B

How is the safe edge added to set A in Kruskal's algorithm ? A. always a max-weight edge B. always a least-weight edge C. Any edge

B

If a problem in NP can be solved in polynomial time, then it is known that all problems in NP can be solved in polynomial time. A. The statement is True, if and only if, the problems in consideration are decision problems. B. False, any problem in P is also in NP and can be solved in Polynomial time. However, it is not known that all problems in NP can be solved in polynomial time. C. False, if a problem in NP can be solved in polynomial time and all other NP problems can be reduced to that problem in Polynomial time, then and then only all problems in NP can be solved in polynomial time. D. The statement is True.

B

In a hash table in which collisions are resolved by chaining, an unsuccessful search takes average-case time A. theta ( α) B. theta (1+ α) C. O (1+ α)

B

In regards to the design of good hash functions, two of the schemes which are heuristic in nature are A. hashing by division and hashing by addition B. hashing by division and hashing by multiplication C. hashing by division and hashing by subtraction

B

Let G be an undirected connected graph with distinct edge weight. Let emax be the edge with maximum weight and emin the edge with minimum weight. Which of the following statements is false? A. G has a unique minimum spanning tree B. No minimum spanning tree contains emax C. If emax is in a minimum spanning tree, then its removal must disconnect G D. Every minimum spanning tree of G must contain emin

B

Quick sort uses A. Merging B. Partitioning C. Exchanging D. Selection

B

The running time of an algorithm on a particular input is the number of A. lines in the algorithm B. primitive operations or "steps" executed

B

There are n people, each in possession of a different rumour. They want to share the news with each other by sending electronic messages. What is the minimum number of messages they need to send to guarantee that every one of them gets all the rumours? A. n − 2 B. 2n − 2 C. 2n − 4 D. 2n + 2

B

What are the Red and black colors used for is a red-black tree? A. They serve no purpose B. They are a part of the balancing of the tree C. Its easier to read D. They show the nodes with no children

B

What is a hash function? A. A function has allocated memory to keys B. A function that computes the location of the key in the array C. A function that creates an array D. None of the mentioned

B

What is meant by a degree of a vertex in an undirected graph? A. The number of neighboring vertex B. The number of edges incident on it

B

What is the model of the implementation technology for analyzing an algorithm? A. Big-theta notation B. Random-access machine model C. Random-accept machine model D. Big O notation model

B

Which of the following statements is/are TRUE for undirected graphs? P: Number of odd degree vertices is even. Q: Sum of degrees of all vertices is even. A. Q only B. Both P and Q C. Neither P nor Q D. P only

B

An alternative method for resolving collisions, is called A. non-collision B. chaining C. open addressing

C

Can a node in a 2-3-4 tree have a single child node? A. Does not matter B. Yes C. No

C

Correct the algorithm if there is any error: GENERIC-MST(G, w) 1. A =ϕ 2. while A does not form a spanning tree 3. find an edge (u,v) that is safe for A 4. A = A ∩ {(u,v)} 5. return A A. A=G B. while A forms a spanning tree C. A = A U {(u,v)} D. return {(u,v)}

C

Despite this slow worst-case running time, quicksort is often the best practical choice for sorting because it is remarkably efficient on the average: its expected running time is A. theta (n ) B. theta (n^2) C. theta (n lg n) D. theta (lg n)

C

One of the simplest collision resolution technique is called C. collision resolution B. non-collision C. chaining

C

Pick correct property of the red-black tree: A. If a node is red, then both its children can be of any color. B. If a node is red, then both its children are red. C. If a node is red, then both its children are black. D. If a node is red, then both its children do not have any color,

C

Red-black trees are one of many search-tree schemes that are "balanced" in order to guarantee that basic dynamic-set operations take A.O(n) time in the worst case B.O(n^2) time in the worst case C. O(lg n) time in the worst case D.O(n^3) time in the worst case

C

Select all the open addressing approaches to hash table collisions: a. Linear probing. b. Quadratic probing. c. Exponential hashing. d. Separate chaining. A. C and D B. None C. A and B D. ALL

C

The Average case complexity of Insertion sort is: A. O(log n) B. O(n) C. О(n^2) D. О(n^3)

C

What are the operations that could be performed in O(logn) time complexity by the red-black tree? A. only insertion B. for sorting C. insertion, deletion, finding predecessor, successor D. only finding predecessor, successor

C

What is the special property of red-black tree? A. Root node is red. B. Root node is either red or black. C. Every node is either red or black. D. Every node can be of any color.

C

Why do we impose restrictions like * root property is black * every leaf is black * children of red node are black * all leaves have same black A. to get linear time complexity B. to get constant time complexity C. to get logarithm time complexity D. to get exponential time complexity

C

A data structure is required for storing a set of integers such that each of the following operations can be done in O(log n) time, where n is the number of elements in the set. I. Deletion of the smallest element II. Insertion of an element if it is not already present in the set Which of the following data structures can be used for this purpose? A. A heap can be used but not a balanced binary search tree B. Both balanced binary search tree and heap can be used C. Neither balanced search tree nor heap can be used D. A balanced binary search tree can be used but not a heap

D

An undirected graph is said to be Hamiltonian if it has a cycle containing all the vertices. Any DFS tree on a Hamiltonian graph must have depth V-1. A. False. If a graph has a Hamiltonian cycle, DFS can never find that cycle and reach a depth of V-1 as finding a Hamiltonian Cycle in a graph is a NP-Complete problem. B. False. If a graph has a Hamiltonian cycle, DFS may be able find that cycle but achieving the tree depth of V-1 is completely unrelated to that. C. True. If a graph has a Hamiltonian cycle, then DFS will definitely find that cycle and the DFS tree will reach the depth V-1. D. False. If a graph has a Hamiltonian cycle, then it is possible, depending on the ordering of the graph that DFS will find that cycle and that the DFS tree will have depth V-1. However, DFS is not guaranteed to find that cycle. If DFS does not find that cycle, then the depth of the DFS tree will be less than V-1.

D

Each node of the Red Black tree now contains the attributes A. color, left, right, B. key, left, right, and p C.key,left, right, D. color, key, left, right, and p

D

Find the dominant term for determining the complexity of (n^2)log_2(⁡n) + n ( log_2(n))^2 : 1.(n^2)log_2 ⁡(n) 2.n^2 3.log_2(n)^2 4.log_2(n) A. 2 B. 3 C. 4 D. 1

D

How can you save memory when storing color information in a Red-Black tree? A. using another array with colors of each node B. storing color information in the node structure C. using negative and positive numbering D. using least significant bit of one of the pointers in the node for color information

D

In general, the time taken by an algorithm grows with the size of the input, so it is traditional to describe the running time of a program as a function of A. the lines of algorithm B. the number of inputs to the algorithm C. the actual time recorded D. The size of its input

D

In simple uniform hashing, what is the search complexity? A. O(n) B. O(logn) C. O(nlogn) D. O(1)

D

T&F: A graph algorithm with Θ (E log V ) running time is asymptotically better than an algorithm with a Θ (E logE) running time for a connected, undirected graph G(V, E).

True

T&F: In an undirected graph G =(V, E ), the edge set E consists of unordered pairs of vertices.

True

T&F: The data types in the RAM model are integer and floating point (for storing real numbers).

True

T&F: The two algorithms for solving the minimum spanning-tree problem are Kruskal's algorithm and Prim's algorithm.

True

T&F: When the graph is undirected, the adjacency relation is symmetric.

True

T/F: A dynamic-programming algorithm solves each sub-problem just once and then saves its answer in a table, thereby avoiding thework of recomputing the answer every time it solves each sub sub problem.

True

T/F: A longest path in a dag G = (V, E) can be found in O(V + E) time.

True

T/F: A red-black tree is a binary search tree with one extra bit of storage per node: its color ( RED or BLACK)

True

T/F: Memoization is the basis for a top-down alternative to the usual bottom-up version of dynamic programming.

True

T/F: The fractional knapsack problem is similar to the 0-1 knapsack problem, but the thief can takefractions of items.

True

T/F: The sibling of a null child reference in a red-black tree is either another null child or a red node.

True


संबंधित स्टडी सेट्स

ITE 152- Exam 1 (Chapters 1, 3, 5)

View Set

Large Animal Clinical Procedures: Ch. 6 Equine Breeds

View Set

ECON 2035 Stahl Chapters 9&10 Questions

View Set

PEDS CH31 - Endocrine Dysfunction 1

View Set

Quiz 6 Med-Surg, Shock-Chapter 19 questions from text book and study guide plus important facts from powerpoint

View Set

CH. 40 Oxygenation and Perfusion Prep U

View Set