Quiz 4

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

Traversal of a graph is different from tree because (A) There can be a loop in graph so we must maintain a visited flag for every vertex (B) DFS of a graph uses stack, but in-order traversal of a tree is recursive (C) BFS of a graph uses queue, but a time efficient BFS of a tree is recursive. (D) All of the above

(A) There can be a loop in graph so we must maintain a visited flag for every

What is the maximum number of edges in an acyclic undirected graph with n vertices? (A) n-1 (B) n (C) n + 1 (D) 2n-1

(A) n-1

Which of the following condition is sufficient to detect cycle in a directed graph? (A) There is an edge from currently being visited node to an already visited node.(B) There is an edge from currently being visited node to an ancestor of currently visited node in DFS forest. (C) Every node is seen twice in DFS. (D) None of the above

(B) There is an edge from currently being visited node to an ancestor of currently visited node in DFS forest.

Given two vertices in a graph s and t, which of the two traversals (BFS and DFS) can be used to find if there is path from s to t? (A) Only BFS (B) Only DFS (C) Both BFS and DFS (D) Neither BFS nor DFS

(C) Both BFS and DFS

Which of the following is true? a) A graph may contain no edges and many vertices b) A graph may contain many edges and no vertices c) A graph may contain no edges and no vertices d) None of the mentioned

a) A graph may contain no edges and many vertices

Regarding implementation of Depth First Search using stacks, what is the maximum distance between two nodes present in the stack? (considering each edge length 1) a) Can be anything b) 0 c) At most 1 d) Insufficient Information

a) Can be anything

A person wants to visit some places. He starts from a vertex and then wants to visit every vertex till it finishes from one vertex, backtracks and then explore other vertex from same vertex. What algorithm he should use? a) Depth First Search b) Breadth First Search c) Trim's algorithm d) None of the mentioned

a) Depth First Search

Adjacency matrix of all graphs are symmetric. a) False b) True

a) False

Which of the following is the most suitable definition of radix sort? a) It is a non-comparison based integer sort b) It is a comparison based integer sort c) It is a non-comparison based non integer sort d) It is a comparison based non integer sort

a) It is a non-comparison based integer sort

Which of the following properties does a simple graph does not hold? a) Must be connected b) Must be unweighted c) Must have no loops or multiple edges d) All of the mentioned

a) Must be connected

Time complexity to find if there is an edge between 2 vertices is _________ a) O(V) b) O(E) c) O(1) d) O(V+E)

a) O(V)

Depth First Search is equivalent to which of the traversal in the Binary Trees? a) Pre-order Traversal b) Post-order Traversal c) Level-order Traversal d) In-order Traversal

a) Pre-order Traversal

. The Data structure used in standard implementation of Depth First Search is?a) Stack b) Queue c) Linked List d) None of the mentioned

a) Stack

For some sparse graph an adjacency list is more space efficient against an adjacency matrix. a) True b) False

a) True

Which of the following is not an example of non-comparison sort? a) bubble sort b) counting sort c) radix sort d) bucket sort

a) bubble sort

What is the advantage of counting sort over quick sort? a) counting sort has lesser time complexity when range is comparable to number of input elements b) counting sort has lesser space complexity c) counting sort is not a comparison based sorting technique d) it has no advantage

a) counting sort has lesser time complexity when range is comparable to number of input elements

What is the full form of MSD in MSD radix sort? a) most significant digit b) many significant digit c) more significant digit d) must significant digit

a) most significant digit

What is the advantage of radix sort over quick sort? a) radix sort performs better than quick sort when we have log n bits for every digit b) radix sort has lesser space complexity c) radix sort is not a comparison based sorting technique d) radix sort has better cache performance than quick sort

a) radix sort performs better than quick sort when we have log n bits for every digit

Counting sort is often used as a sub routine for radix sort. a) true b) false

a) true

The given Graph is regular. a) True b) False

a) true

What is the number of edges present in a complete graph having n vertices? a) (n*(n+1))/2 b) (n*(n-1))/2 c) n d) Information given is insufficient

b) (n*(n-1))/2

What will be the order of elements of the array arr = {23, 67, 143, 654, 43} after first iteration of MSD sort is complete? a) 23, 43, 67, 143, 654 b) 23, 67, 43, 143, 654 c) 23, 67, 143, 654, 43 d) 23, 143, 43, 654, 67

b) 23, 67, 43, 143, 654

A person wants to visit some places. He starts from a vertex and then wants to visit every place connected to this vertex and so on. What algorithm he should use? a) Depth First Search b) Breadth First Search c) Trim's algorithm d) None of the mentioned

b) Breadth First Search

Which of the following uses the largest amount of auxiliary space for sorting? a) Bubble sort b) Counting sort c) Quick sort d) Heap sort

b) Counting sort

It is not possible to implement counting sort when any of the input element has negative value. a) True b) False

b) False

MSD radix sort is an in-place sorting algorithm. a) True b) False

b) False

MSD radix sort should be preferred over LSD radix sort when we have to maintain the original relative order. a) True b) False

b) False

Which of the following statement is not a stable sorting algorithm? a) LSD radix sort b) MSD radix sort c) Counting sort d) Pigeonhole sort

b) MSD radix sort

What is the average time complexity of counting sort? a) O(n) b) O(n+k) k=range of input c) O(n2) d) O(n log n)

b) O(n+k) k=range of input

What is the average time complexity of MSD radix sort (w= bits required to store each key)? a) O(n + w) b) O(n.w) c) O(n2) d) O(n log n)

b) O(n.w)

The Data structure used in standard implementation of Breadth First Search is? a) Stack b) Queue c) Linked List d) None of the mentioned

b) Queue

Which of the following is not true about radix sort? a) Radix sort performs better than quick sort when we have log n bits for every digit b) Radix sort has better cache performance than quick sort c) Radix sort has higher values of constant factor in asymptotic notation d) Radix sort takes more space than quick sort

b) Radix sort has better cache performance than quick sort

A graph with all vertices having equal degree is known as a __________ a) Multi Graph b) Regular Graph c) Simple Graph d) Complete Graph

b) Regular Graph

The Breadth First Search traversal of a graph will result into? a) Linked List b) Tree c) Graph with back edges d) All of the mentioned

b) Tree

The Depth First Search traversal of a graph will result into? a) Linked List b) Tree c) Graph with back edges d) None of the mentioned

b) Tree

When the Breadth First Search of a graph is unique? a) When the graph is a Binary Tree b) When the graph is a Linked List c) When the graph is a n-ary Tree d) None of the mentioned

b) When the graph is a Linked List

When the Depth First Search of a graph is unique? a) When the graph is a Binary Tree b) When the graph is a Linked List c) When the graph is a n-ary Tree d) None of the mentioned

b) When the graph is a Linked List

Which of the following statement is true about comparison based sorting? a) counting sort is a comparison based sort b) any comparison based sorting can be made stable c) bubble sort is not a comparison based sort d) any comparison based sort requires at least O(n2) time

b) any comparison based sorting can be made stable

Which of the following sorting techniques is stable? a) quick sort b) counting sort c) heap sort d) selection sort

b) counting sort

In a simple graph, the number of edges is equal to twice the sum of the degrees of the vertices. a) True b) False

b) false

For the adjacency matrix of a directed graph the row sum is the _________ degree and the column sum is the ________ degree. a) in, out b) out, in c) in, total d) total, out

b) out, in

Which of the following algorithm takes nonlinear time for sorting? a) counting sort b) quick sort c) bucket sort d) radix sort

b) quick sort

Which of the following is an alternate name of MSD radix sort? a) bottom up radix sort b) top down radix sort c) forward radix sort d) backward radix sort

b) top down radix sort

Which of the following ways can be used to represent a graph? a) Adjacency List and Adjacency Matrix b) Incidence Matrix c) Adjacency List, Adjacency Matrix as well as Incidence Matrix d) None of the mentioned

c) Adjacency List, Adjacency Matrix as well as Incidence Matrix

Regarding implementation of Breadth First Search using queues, what is the maximum distance between two nodes present in the queue? (considering each edge length 1) a) Can be anything b) 0 c) At most 1 d) Insufficient Information

c) At most 1

In Depth First Search, how many times a node is visited? a) Once b) Twice c) Equivalent to number of indegree of the node d) None of the mentioned

c) Equivalent to number of indegree of the node

On which of the following statements does the time complexity of checking if an edge exists between two vertices is not, depends? a) Depends on the number of edges b) Depends on the number of vertices c) Is independent of both the number of edges and vertices d) It depends on both the number of edges and vertices

c) Is independent of both the number of edges and vertices

Breadth First Search is equivalent to which of the traversal in the Binary Trees?a) Pre-order Traversal b) Post-order Traversal c) Level-order Traversal d) In-order Traversal

c) Level-order Traversal

Space complexity for an adjacency list of an undirected graph having large values of V (vertices) and E (edges) is ___________ a) O(E) b) O(V*V) c) O(E+V) d) O(V)

c) O(E+V)

The complexity of which of the following sorting algorithms remains to be the same in its best, average and worst case? a) quick sort b) insertion sort c) counting sort

c) counting sort

Which of the following sorting techniques is most efficient if the range of input data is not significantly greater than a few elements to be sorted? a) selection sort b) bubble sort c) counting sort d) insertion sort

c) counting sort

In BFS, how many times a node is visited?a) Once b) Twice c) equivalent to number of indegree of the node d) None of the mentioned

c) equivalent to number of indegree of the node

Which of the following is not true about MSD radix sort? a) its processing starts from the most significant digit b) it is not a stable sort c) it is an in place sorting algorithm d) it is non-comparison based sort

c) it is an in place sorting algorithm

Complete the given snippet of code for the adjacency list representation of a weighted directed graph. class neighbor { int vertex, weight; ____ next; } class vertex { string name; _____ adjlist; } vertex adjlists[101]; a) vertex, vertex b) neighbor, vertex c) neighbor, neighbor d) vertex, neighbor

c) neighbor, neighbor

Given two vertices in a graph s and t, which of the two traversals (BFS and DFS) can be used to find if there is path from s to t? a. Only BFS b. Only DFS c. Both BFS and DFS d. Neither BFS nor DFS

c. Both BFS and DFS

How many comparisons will be made to sort the array arr = {1, 5, 3, 8, 2} using MSD radix sort? a) 5 b) 7 c) 9 d) 0

d) 0

How many comparisons will be made to sort the array arr={1,5,3,8,2} using counting sort? a) 5 b) 7 c) 9 d) 0

d) 0

The number of elements in the adjacency matrix of a graph having 7 vertices is __________ a) 7 b) 14 c) 36 d) 49

d) 49

What can be the applications of Breadth First Search? a) Finding shortest path between two nodes b) Finding bipartiteness of a graph c) GPS navigation system d) All of the mentioned

d) All of the mentioned Explanation: Breadth First Search can be applied to all the mentioned problems. Bipartiteness of a graph means that a graph can be divided into two disjoint sets such that every edge connects a vertex in to one in.

What can be the applications of Depth First Search? a) For generating topological sort of a graph b) For generating Strongly Connected Components of a directed graph c) Detecting cycles in the graph d) All of the mentioned

d) All of the mentioned Explanation: Depth First Search can be applied to all of the mentioned problems.

What is the disadvantage of counting sort? a) counting sort has large time complexity b) counting sort has large space complexity c) counting sort is not a comparison-based sorting technique d) counting sort cannot be used for array with non-integer elements

d) counting sort cannot be used for array with non-integer elements

Which of the following combines qualities of MSD radix sort and LSD radix sort? a) in-place MSD radix sort b) stable MSD radix sot c) 3 way radix quick sort d) forward radix sort

d) forward radix sort


Conjuntos de estudio relacionados

"Damage and Deterioration" vocabulary

View Set

3.1 Given a scenario, implement secure protocols.

View Set

Adding Charts to Your Presentation (Assignment)

View Set

Worksheet 27.3: Defenses, Limitations, and Discharge

View Set

Sustainable Construction Chapters 1-2

View Set