Quiz 6 - Graphs and Graph Traversal

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

The shortest path between two vertices is a path with the minimum total weights. Question 28 options: A) True B) False

a

Many real-world problems can be solved using graph algorithms. Question 10 options: A) True B) False

a

Representing a graph is to store its vertices and edges in a program. The data structure for storing a graph is arrays or lists. Question 11 options: A) True B) False

a

Suppose a weighted graph is created with the following code. What is the shortest path from vertex 4 to 0? Integer[] vertices = {0, 1, 2, 3, 4}; int[][] edges = { {0, 1, 9}, {0, 2, 5}, {1, 0, 9}, {1, 2, 6}, {1, 3, 4}, {1, 4, 7}, {2, 0, 5}, {2, 1, 6}, {2, 3, 3}, {3, 1, 4}, {3, 2, 3}, {3, 4, 1}, {4, 1, 7}, {4, 3, 1} }; WeightedGraph<Integer> graph1 = new WeightedGraph<>(vertices, edges); WeightedGraph<Integer>.ShortestPathTree tree1 = graph1.getShortestPath(graph1.getIndex(0)); System.out.println("Shortest path from 4 to 0 is " + tree1.getPath(4)); Question 33 options: A) 4 3 2 0 B) 4 1 2 0 C) 4 1 3 2 0 D) 4 3 1 0 E) 4 1 0

a

Suppose you have a directed graph representing all the flights that an airline flies. What algorithm might be used to find the best sequence of connections from one city to another? Question 3 options: A) A shortest-path algorithm. B) Depth first search. C) A cycle-finding algorithm. D) Breadth first search.

a

The Breadth First Search algorithm has been implemented using the queue data structure. One possible order of visiting the nodes of the following graph is Question 34 options: A) Q M N P R O B) M N O P Q R C) Q M N P O R D) N Q M P O R

a

The Minimum Spanning Tree (MST) class is a subtype of _____________. Question 30 options: A) AbstractGraph.Tree B) AVLTree C) Tree D) Binary Search Tree (BST)

a

The breadth-first search of a graph visits the vertices level by level. The first level consists of the starting vertex. Each next level consists of the vertices adjacent to the vertices in the preceding level. Question 13 options: A) True B) False

a

The depth-first search of a graph starts from a vertex in the graph and visits all vertices in the graph as far as possible before backtracking. Question 12 options: A) True B) False

a

The time complexity of the Depth First Search algorithm is O(|E| + |V|). Question 24 options: A) True B) False

a

What graph traversal algorithm uses a queue to keep track of vertices which need to be processed? Question 9 options: A) Breadth-first search. B) Depth-first search.

a

What is the number of edges in a complete graph of n vertices? Question 21 options: A) n(n-1)/2 B) n*n C) n - 1 D) n

a

You can reference a vertex, of a graph, by its name or its _____________ . Question 17 options: A) index B) number of edges C) path D) boolean

a

You can represent a graph using an adjacency matrix or adjacency lists. Question 18 options: A) True B) False

a

Select all of the correct responses. The WeightedGraph is a subtype of _________. Select 2 correct answer(s) Question 29 options: A) AbstractGraph B) Graph C) WeightedEdge D) UnweightedGraph

a, b

A Depth First Search of a directed graph always produces the same number of tree edges, i.e., independent of the order in which vertices are considered. Question 35 options: A) True B) False

b

A connected graph is a(n) _____________ if it does not have cycles. Question 16 options: A) spanning tree B) tree C) object D) weighted graph

b

Graph traversal is the process of visiting each vertex in the graph exactly _________ time(s). Question 14 options: A) two B) one C) unlimited number of D) zero

b

How are loops represented in an edge-list representation of a graph? Question 6 options: A) The edge-list will be full for that particular vertex. B) A vertex will be on its own edge-list. C) The edge-list will be a circular linked list. D) The edge-list will be empty for that particular vertex.

b

If a graph is very sparse (i.e., very few edges), using a(n) ________________ is better, Question 19 options: A) edge list B) adjacency lists C) adjacency matrix D) object matrix

b

The WeightedGraph class extends AbstractGraph. Question 27 options: A) True B) False

b

The ____________ search of a graph first visits a vertex, then it recursively visits all the vertices adjacent to that vertex. Question 23 options: A) breadth-first B) depth-first C) minimum D) maximum

b

The ______________ search of a graph first visits a vertex, then all its adjacent vertices, then all the vertices adjacent to those vertices, and so on. Question 26 options: A) minimum B) breadth-first C) maximum D) depth-first

b

The getMinimumSpanningTree() method returns _____________. Question 31 options: A) a queue B) a Minimum Spanning Tree (MST) C) a LinkedList D) an ArrayList

b

Which graph representation allows the most efficient determination of the existence of a particular edge in a graph? Question 7 options: A) An adjacency matrix. B) Edge lists.

b

A simple graph has no loops. What other property must a simple graph have? Question 2 options: A) It must have at least one vertex. B) It must be directed. C) It must have no multiple edges. D) It must be undirected.

c

How many linked lists are used to represent a graph with n nodes and m edges, when using an edge list representation? Question 5 options: A) m*n B) m C) n D) m + n

c

If G is an directed graph with 20 vertices, how many boolean values will be needed to represent G using an adjacency matrix? Question 4 options: A) 20 B) 40 C) 400 D) 200

c

Suppose a graph is created in the following code. Using the depth first search algorithm in the text, what is the output for the path from 4 to 0? Integer[] vertices = {0, 1, 2, 3, 4}; int[][] edges = { {0, 1}, {0, 2}, {1, 0}, {1, 2}, {1, 3}, {1, 4}, {2, 0}, {2, 1}, {2, 3}, {3, 1}, {3, 2}, {3, 4}, {4, 1}, {4, 3} }; Graph<Integer> graph1 = new UnweightedGraph<>(vertices, edges); AbstractGraph<Integer>.Tree dfs = graph1.dfs(0); System.out.println(dfs.getPath(4)); Question 25 options: A) [4, 1, 2, 0] B) [4, 3, 2, 0] C) [4, 3, 2, 1, 0] D) [4, 3, 1, 0]

c

Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first checking that the vertex has not been visited earlier. Then the maximum possible recursion depth (including the initial call) is Question 36 options: A) 3 B) 28 C) 19 D) 21

c

Which of the following statements is true? Question 1 options: A) A graph must have at least one edge. B) A graph can only be drawn on paper. C) A graph must have at least one vertex. D) Graph vertices may be linked in any manner.

c

A __________ is an edge that links a vertex to itself. Question 20 options: A) directed edge B) weighted edge C) parallel edge D) loop

d

Assume n vertices are in the graph and m edges terminate at the desired node. What is the expected number of operations needed to loop through all the edges terminating at a particular vertex given an adjacency matrix representation of the graph? Question 8 options: A) O(m)^2 B) O(n) C) O(m) D) O(n)^2

d

In a _____________ graph, each edge has a direction, which indicates that you can move from one vertex to the other through the edge. Question 15 options: A) undirected B) theoretical C) universal D) directed

d

The ShortestPathTree class is subtype of a _______________. Question 32 options: A) Tree B) Binary Serach Tree C) AVLTree D) AbstractGraph.Tree

d

What is the number of edges in a tree of n vertices? Question 22 options: A) n B) n(n-1)/2 C) n*n D) n - 1

d


Kaugnay na mga set ng pag-aaral

Abnormal Psych Ch. 10 Sexuality/Gender

View Set

SHRM-CP (Dory Review Book- Ch.4 People)

View Set

Review Test Submission: Chapter 15 Practice

View Set

Communication (Ch. 10-14) NUR 102

View Set

11.1 familiar commands - affirmativos y negativos de estos verbos y Prática 1 - Completar

View Set

Parole spagnole che iniziano per B

View Set

Exam 3 - foundations (engage fundamentals post tests)

View Set