cse374 final exam quiz questions

¡Supera tus tareas y exámenes ahora con Quizwiz!

True or False: Prim's algorithm executed on a planar graph will perform best when the priority queue is implemented using an array.

False

True or False: The subtree of the root of a red-black tree is always itself a red-black tree (as per the standard definition).

False

Find the dominant term for determining the complexity of n^2 * log_2(n) + n * ( log_2(n) )^2. A. n^2 * log_2(n) B. n^2 C. log_2 * n^2 D. log_2(n)

A

Dynamic programming is typically applied to A. optimization problems. B. non-optimization problems C. any problem. D. nondeterministic polynomial (NP) problems.

A

Given a set of non-negative integers and a value K, determine if there is a subset of the given set with sum equal to K. Which paradigm can be used to find the solution to the stated problem in minimum time? A. Dynamic programming B. Divide-and-conquer C. Greedy algorithm D. Branch and bound

A

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 multiplication. B. hashing by division and hashing by addition. C. hashing by division and hashing by substraction.

A

Insertion sort works A. in place. B. out of place.

A

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

A

MST algorithms work 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, ... , x_m> and Y = <y1, y2, ... , y_k> 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

The 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

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. All are correct B. 1 & 2 are correct C. None are correct D. 2 & 3 are correct

A

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

B

A greedy strategy usually progresses in a A. bottom-up fashion. B. top-down fashion. C. (neither)

B

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

B

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

B

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^2) B. theta (n lg n) C. theta (lg n) D. theta (n)

B

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. Both balanced binary search tree and heap can be used B. A heap can be used but not a balanced binary search tree C. A balanced binary search tree can be used but not a heap D. Neither a balanced search tree nor a heap can be used

C

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

C

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

C

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

D

Each node of the red-black tree contains the attributes A. key, left right, and p. B. color, left, and right. C. key, left, and right. D. color, key, left, right, and p.

D

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

D

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 is the following statements is false? A. Every minimum spanning tree of G must contain emin. B. If emax is in a minimum spanning tree, then its removal must disconnect G. C. G has a unique minimum spanning tree. D. No minimum spanning tree contains emax.

D

True or False: A dynamic programming algorithm solves each subproblem just once and then saves its answer in a table, thereby avoiding the work of re-computing the answer every time it solves each sub problem.

True

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

A

An undirected graph has n nodes. Its adjacency matrix is given by an n * n square matrix whose diagonal elements are zeroes and non-diagonal elements are ones. Which of the following is TRUE? A. Graph G has multiple distinct MSTs, each of cost n - 1 B. Graph G has multiple spanning trees of different costs C. Graph G has a unique MST of cost n - 1 D. Graph G has no MST

A

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

A

Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry W_(ij) 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 zero is a leaf node in the tree T? 00 01 08 01 04 01 00 12 04 09 08 12 00 07 03 01 04 07 00 02 04 09 03 02 00 A. 10 B. 9 C. 8 D. 7

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, 6 swaps C. 5 comparisons, 4 swaps D. 4 comparisons, 5 swaps

A

Consider the strings "PQRSTPQRS" AND "PRATPBRQRPS". What is the length of the longest common subsequence? A. 7 B. 8 C. 9 D. 6

A

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

A

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

A

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

A

The worst-case running time of an algorithm A. gives us an upper bound on the running time for any input. B. does not occur often. C. is often very bad compared to "average case". 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) is-in 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. V + S D. S

A

What do we mean by "programming" in the context of dynamic programming? A. A tabular method B. Writing code C. Writing Java code

A

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

A

Select all the open addressing approaches to hash table collisions: A. Linear probing B. Quadratic probing C. Exponential hashing D. Separate chaining

A & B

Select from the following methods which can be used to solve the longest common subsequence problem. A. Recursion B. Dynamic programming

A & B

What are the two equivalent ways to implement a dynamic-programming approach? A. Top-down with memoization B. Bottom-up method C. Bottom-down method D. Top-up with memoization

A & B

Which of the following statements is/are TRUE for undirected graphs? A. Number of odd-degree vertices is even. B. Sum of degrees of all vertices is even.

A & B

Select all that apply: 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

All of the above

An undirected graph G has n nodes. Its adjacency matrix is given by an n * n square matrix whose diagonal elements are zeroes and non-diagonal elements are ones. Which of the following is TRUE? A. Graph G has no MST. B. Graph G has multiple distinct MSTs, each of cost n - 1 C. Graph G has a unique MST of cost n - 1 D. Graph G has multiple spanning trees of different costs

B

Dynamic programming approach is used when A. it provides an optimal solution. B. the solution has optimal substructure. C. the given problem can be reduced to the 3-SAT problem. D. it's faster than greedy.

B

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

B

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

B

Is a tree with all black nodes a red-black tree? A. Yes, always. B. Yes, but the tree has to be a perfect binary tree. C. No.

B

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

B

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

B

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

B

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

B

What is NOT a property of a greedy algorithm? A. Overlapping subproblems B. Non-overlapping subproblems C. Greedy choices D. Optimal substructure

B

What is a hash function? A. A function that 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 above)

B

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

B

What is the special property of red-black trees and what should the root always be? A. All nodes are black. B. Nodes are either red or black but the root should always be black. C. Nodes are either green or black. D. Nodes contain a pointer to the next node and the root should always be black.

B

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

B

Which is NOT a property of a greedy algorithm? A. Greedy choice B. Non-overlapping subproblems C. Optimal substructure D. Overlapping subproblems

B

Why do we impose restrictions such as: * root property is black * every leaf is black * children of a red node are black * all leaves are black A. To get constant time complexity. B. To get logarithmic time complexity. C. To get linear time complexity. D. To get exponential time complexity.

B

When developing a dynamic-programming algorithm, we follow a sequence of steps. Choose the correct options below: A. Characterize the structure of a non-optimal solution. B. Recursively define the value of an optimal solution. C. Compute the value of an optimal solution, typically in a bottom-down fashion. D. Construct an optimal solution from computer information.

B & 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 number of inputs to the algorithm. B. the actual time recorded. C. the size of its input. D. the number of lines of the algorithm.

C

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

C

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

C

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

C

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

C

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

C

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

C

What are the red-black tree operations that could be performed in O(log n) time? A. Sorting operations. B. Operations that find the predecessor and successor. C. Insert, delete, find predecessor, find successor. D. Insert.

C

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

C

Which of the following is a self-adjusting or self-balancing binary search tree? A. AVL tree B. Red-black tree C. Both of these D. Neither of these

C

Which of the following operations are used by red-black trees to maintain balance during insertion and deletion? A. Recoloring of nodes B. Left rotations and right rotations C. Both of these D. Neither of these

C

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

D

An undirected graph is said to be Hamiltonian if a cycle containing all the vertices. Any depth-first search (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 to 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

Quicksort uses A. selection. B. merging. C. exchanging. D. partitioning.

D

Quicksort, like merge sort, applies the A. recursion paradigm. B. greedy paradigm. C. iterative paradigm. D. divide-and-conquer paradigm.

D

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

D

There are n people, each in possession of a different rumor. 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 rumors? A. 2n + 2 B. n - 2 C. 2n - 4 D. 2n - 2

D

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

D

What is the time complexity of the brute force algorithm used to find the LCS? A. O(n) B. O(n^2) C. O(n^3) D. O(2^n)

D

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

D

True or False: A graph algorithm with theta (E log V) running time is asymptotically better than an algorithm with a theta (E log E) running time for a connected, undirected graph G (V, E).

False

True or False: A heap of n elements can be converted into a binary search tree in O(n) time.

False

True or False: A heap with n elements can be converted into a binary search tree in O(n) time.

False

True or False: In an undirected graph, self-loops are possible.

False

True or False: 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

True or False: A heap can be constructed from an unordered array of numbers in linear worst-case time.

True

True or False: A longest path in a directed acyclic graph (DAG) G = (V, E) can be found in O(V + E) time.

True

True or False: A red-black tree is a binary search tree with one extra bit of storage per node: its color (red or black).

True

True or False: A red-black tree on 128 keys must have at least one red node.

True

True or False: Given a graph G = (V, E) with a cost on edges and a set S(is-in)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 edges are distinct.)

True

True or False: In an undirected graph G = (V, E), the edge set E consists of unordered pairs of vertices.

True

True or False: Memoization is the basis for a top-down alternative to the usual bottom-up version of dynamic programming.

True

True or False: The data types in the RAM model are integer and floating point (for storing real numbers).

True

True or False: The fractional knapsack problem is similar to the 0-1 knapsack problem, but the thief can take fractions of items.

True

True or False: The sibling of a null child reference in a red-black tree is either another null child or a red node.

True

True or False: The two algorithms for solving the minimum spanning tree problem are Kruskal's algorithm and Prim's algorithm.

True

True or False: When the graph is undirected, the adjacency relation is symmetric.

True


Conjuntos de estudio relacionados

৩.১ বাংলাদেশের ভূ-প্রকৃতি, অবস্থান, জলবায়ু

View Set

Lesson 25 Quiz: Advertising Rules and Regulations

View Set

UIUC Psych 238 Quiz 1 (Chs 1,2,3,4)

View Set

FIN 421 lecture 1 interest rates

View Set