CSE 375 Car Fax

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

Red-black trees are one of many search tree schemes that are "balanced" in order to garuntee that basic dynamic-set operations take

O(lgn) time in the worst case

The average case complexity of insertion sort is

O(n^2)

An alternative method for resolving collisions, is called

Open addressing

To implement Dijkstra's shortest path algorithm on unweighted graphs so that it runs in linear time, the data structure to be used is:

Queue

What does RAM stand for

Random Access Machine

What is the model of the implementation technology for analyzing an algorithm?

Random-Access Machine Model

What is recurrence for the worst case of QuickSort and what is the time complexity in the Worst case?

Recurrence is T(n) = T(n-1) + O(n) and time complexity is O(n^2)

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

Row-Major order

The insertion sort has a worst-case running time of

Theta of n-squared

For a given function g(n), what does the below function represent? {f (n) : there exist positive constants c1, c2, and n0 such that0 <= c1g(n) <= f (n) <= c2g(n) for all n >= n0}

Theta(g(n))

What are the red and black color used for is a red-black tree?

They are a part of the balancing of the tree

Is a tree with all black nodes a red-black tree?

Yes, The tree has to be a perfect binary tree

Will Dijkstra's algorithm work for an undirected graph?

Yes, if an un directed edge is viewed as combination of two edges directed at opposite directions

Can node in 2-3-4 tree have a single child node?

No

Can you solve the following recurrence using Master's Theorem: T(n)=2T(n/2)+n/log(n) ?

No

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: G has a unique mst no MST tree contains emax Every MST of G must contain emin if emax is in a MST, then its removal must disconnect G

No MST contains emax

What is not the property of a greedy algorithm?

Non Overlapping sub problems

What is not the property of a greedy algorithm: Overlapping sub problems Non overlapping Sub Problems Greed Choice Optimal subtree

Non overlapping sub problems

In simple uniform hashing, what is the search complexity?

O(1)

The time required to compute the hash value h(k) is

O(1)

SEARCH, MINIMUM, MAXIMUM, SUCCESSOR, and PREDECESSOR operations on red-black trees takes

O(lgn)

What is meant by a degree of a vertex in an undirected graph?

The number of edges incident on it

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

1 & 2, Top down with memoization, bottom-up method

In a hash table of size 13 which index positions would the following two keys map to? 27, 130

1, 0

Find the dominant term for determining the complexity of n2log2n+n(log2n)2n2log2⁡n+n(log2⁡n)2 : 1.n2log2nn2log2⁡n 2.n2n2 3.log2n2log2⁡n2 4.log2n

1, N^2 log(base 2) n

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.

2&4

A red-black tree with n internal nodes has height at most

2(lgn+1)

In this sequence, 11 4 20 45 32 60 98 70, which element seems to be the pivot?

20

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 minim number of messages they need to send to grantee that everyone gets all the rumors.

2n-2

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

3, Both recursion and dynamic programming

Dynamic programming approach is used when: 1. It provides optical solution 2. The solution has optimal substructure 3. The given problem can be reduced the the 3-SAT problem 4. Its faster than greedy

3, its faster than greedy

Which of the following statements about NP-Hardness are correct? 1. Some of the co-NP problems can also be NP-hard as long as they are reducible from other NP problems. 2. The hardest NP problems are called NP-hard problems. 3. 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. 4. Some NP-hard decision problems can be verified in Polynomial time.

3,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. Some NP-hard decision problems can be verified in Polynomial time.

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)

4, O(2n)

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]

6 comparisons, 5 swaps

Consider the strings "PQRSTPQRS" and "PRATPBRQRPS". What is the length of the longest common subsequence?

7

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 U {(u,v)}

Select all the open addressing approaches to the has table collisions: a. Linear probing. b. Quadratic probing. c. Exponential hashing. d. Separate chaining.

A and B, Linear Probing, Quadratic Probing

A data structure is required for storing a set of integers such that each of the following operations can be done in O(logn) 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 balanced binary search tree can be used but not a heap

What is the special property of red-black trees and what root should always be?

A color which is either red or black and root should always be black color only

A binary tree is composed of three disjoint set of nodes:

A root node, Left subtree, right subtree

What do you mean by "programming" in the context of dynamic programming?

A tabular method

LCS for input Sequences "ABCDGH" and "AEDFHR" is

ADH" of length 3

The sub-tree of the root of a red-black tree is always itself a red-black tree (as per standard definition)

False

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?

All are correct.

Which of the following is a self-adjusting or self-balancing binary search tree? AVL Tree Red black Tree All of the above

All of the above

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.

All of the mentioned: Uniform Distribution, Speedy computation, The range is a subset of the integers, Equivalent objects produce equal has codes

Prims algorithm executed on a planar graph will perform best when the priority queue is implemented using an array

False

The recurrence relation T(n) = 4T(n/2) + n2 /lg n can be best solved using Master Method

False

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, A function that computes the location of the key in the array

When we have only an asymptotic upper bound, we use

Big Oh notation

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.

Both P and Q

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)

Both a and B

Each node of the red black tere now contains the attributes

Color, key, left , right and p

Each node of Red Black tree now contains the attributes

Color, key, left, right, and p

A ________________ of a connected graph is a minimal set of edges whose removal separate the graph into two components.

Cut

In simple uniform hashing, what is the search complexity? a) O(n) b) O(logn) c) O(nlogn) d) O(1)

D, O(1)

Quick sort, like merge sort, applies the

Divide and conquer paragigm

The following paradigm can be used to find the solution of the problem in minimum time: given a set of no-negative integer and a value k, determine if there is a subset of the given set with sum equal to K:

Dynamic Programing

What is the special property of red-black tree

Every node is either red or black

A graph algorithm with Theta(ElogV) running time is asymptotically better than an algorithm with a Theta(ElogE) running time for a connected, undirected graph G(V,E)

False

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

False

In an undirect graph, self-loops are possible.

False

Insertion in a binary search tree is "commutative". That is, interesting x and then y into a binary search tree leave as the same tree as inserting y and then x

False

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

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

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.

False. If a graph has a hamiltonian cycle, then it is possible, depending on the ordering og the graph that DFS will find that cycle and that the DFS tree will have depth V-1. However, DFS is not garunteed to find that cycle. If DFS does not find that cycle, then the depth of the DFS tyree will be less than v-1

LCS for input Sequences "AGGTAB" and "GXTXAYBB" is

GTAB

An undirected graph G has n nodes. Its adjacency matrix is given by an n x n square matrix whose (i) diagonal elements are 0's and (ii) non-diagonal elements are 1's. Which one the following is TRUE?

Graph g has multiple distinct MSTs, each of cost n-1

Which approach cannot be used to solve the 0-1 knapsack problem?

Greedy Strategy

Pick correct property of the red-black tree: 1. If a node is red, then both its children can be of any color. 2. If a node is red, then both its children are black 3. if a node is red, then both its children do not have any color, 4. If a node is red, then both its children are red

If a node is red-black tree, then both its children are black

In regards to the design of good hash functions, two of the schemes which are heuristic in nature are

Hashing by division and hashing by multiplication

Insertion Sort works in place or out of place?

In place

Insertion sort works in place or out of place?

In place

What are the operations that could be performed in O(logn) time complexity by the red black tree?

Insertion, deletion, finding predecessor, successor

Quick sort uses

Partitioning

Linear probing is easy to implement, but it suffers from a problem known as

Primary clustering

A data structure for maintaining a set S of elements, each with an associated value called a key.

Priority queue

Why do we impose restrictions like 1. Root property is black 2. every leaf is black 3. Children of red node are black 4. All leaves have same black

To get logarithm time complexity

A greedy strategy usually progresses in a

Top-Down Fashion

For the problem of multiplying two integers what will best measure of the input size?

Total number of bits needed to represent the input in binary

A heap can be constructed for an unordered array of numbers in linear worst-case time.

True

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

True

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

True

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.)

True

In an undirect graph G = (V,E), the edge set E consists of unordered pairs of vertices.

True

Like insertion sort, heapsort sorts in place: only a constant number of arrayelements are stored outside the input array at any time.

True

Memoization is the basis for a top-down alternative to the usual bottom-up version of dynamic programming

True

The BFS algorithm discovers all vertices at distance k from s before discovering any vertices at distance k+1.

True

The data types in the RAM model are integer and floating point (for storing real numbers)

True

The fractional knapsack problem is similar to the 0-1 knapsack problem, but the thief can take fractions of times.

True

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

True

The two algorithms for solving the minimum panning-tree problem are Kruskal's algorithm and Prim's algorithm

True

The worst-case running time gives an ______ bound on the running time for any input

Upper

How can you save memory when storing color information in a red black tree?

Using the least significant bit of one of the pointers in the node for color information

We say that an edge (u,v) is an element of E crosses the cut (s,v-s) if one of its endpoints is in the S and the other is in _____

V-S

MST algorithms works on which of the following type(s) of graph

Weighted, connected, undirected

How is the safe edge added to set A in kruskal's algorithm

always a least-weight edge

Unlike dynamic programming, which solves the subproblems before making the first choice, a greedy algorithm makes it first choice _____

before solving any subproblems

The worst-case running time of an algorithm

gives us an upper bound on the running time for any input

One of the simplest collision resolution technique is called

chaining

An edge is a light edge satisfying a given property if its weight is the

minimum of any edge satisfying the property

Eval quiz week 6, question 26.

okay

Dynamic programming is typically applied to

optimization problems

The running time of an algorithm on a particular input is the number of

primitive operations or steps executed

Given a hash table T with m slots that stores n elements, we define the load factor as

the average number of elements stored in a chain

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

the size of its input

In a hash table in which collisions are resolved by chaining, an unsuccessful search takes average-case time

theta (1+ α)

The insertion sort has a worst-case running time of

theta n-squared

On an input array of n numbers, the quicksort algorithm has a worst-case running time of

theta(n^2)

Despite this slow worst case running time, quicksort is often the best practical choice for sorting because it is remarkable efficient on the average; its expected running time is

theta(nlgn)

Dynamic programming thus uses additional memory to save computation time; it serves an example of a

time-memory trade-off

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

true

A heap can be constructed from an unordered array of numbers in linear worst-case time

true

A red-black tree on 128 keys must have at least 1 red node

true

When the graph is undirected, the adjacency relation is symmetric

true

You have two Dictionary implementations, one using a sorted array, one using an unsorted array. Assume that you know ahead of time what the maximum number of key-value pairs is that you will everneed to store at any point in time (i.e. you never increase the size of the array). For the following operations, please write "sorted", "unsorted", or "same" to indicate which implementation has the fasterworst-case runtime (or if they are the same).• Insert a new key-value pair:• Given a key, remove a key-value pair:• Look up the value for a given key:• Update the value for a given key:

unsorted, same, sorted, sorted


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

Ch 12: Measurement and Knowledge Management for Performance Excellence

View Set

AP Human Geography Chapter 8 - Political Geography

View Set

Brain & Special Senses Lab: Eyes

View Set

WA Driving Test - Road Signs Mini

View Set