Filters
Question type

Study Flashcards

In the following code to add an edge in the LinkedDirectedGraph class, what is the missing code? def addEdge(self, fromLabel, toLabel, weight) : FromVertex = self.getVertex(fromLabel) < missing code > FromVertex.addEdgeTo(toVertex, weight) Self.edgeCount += 1


A) self.getVertex(toLabel) = fromVertex
B) fromVertex.addEdgeTo(fromVertex, weight)
C) self.weight += 1
D) toVertex = self.getVertex(toLabel)

E) A) and D)
F) C) and D)

Correct Answer

verifed

verified

Which of the following is NOT true after the initialization step in Dijkstra's algorithm?


A) the cells in the included list are all False, except for the cell that corresponds to the row of the source vertex in the results grid
B) the distance in a row's distance cell is either 0, infinity, or a positive number
C) the shortest path from the source to a vertex is found and the vertex's cell is marked in the included list
D) the vertex in a row's parent cell is either the source vertex or undefined

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

A graph has a single length attribute, similar to the lists, queues, and stacks.

A) True
B) False

Correct Answer

verifed

verified

The adjacency matrix representation of a graph stores graph information in an array of lists.

A) True
B) False

Correct Answer

verifed

verified

In a connected graph, there must be an edge from each vertex to every other vertex.

A) True
B) False

Correct Answer

verifed

verified

A topological order assigns a rank to each edge such that the vertices go from lower-to higher-ranked edges.

A) True
B) False

Correct Answer

verifed

verified

In a complete graph with six vertices, the degree of a vertex is five.

A) True
B) False

Correct Answer

verifed

verified

In an adjacency matrix, a 1 is used to represent an edge between two vertices.

A) True
B) False

Correct Answer

verifed

verified

What are edges called that emanate from a given source vertex?


A) incident edges
B) directed edges
C) destination edges
D) cyclical edges

E) A) and B)
F) All of the above

Correct Answer

verifed

verified

A

In a complete undirected graph with five vertices how many cells will contain a value of 1 in an adjacency matrix?


A) 15
B) 10
C) 25
D) 125

E) All of the above
F) B) and D)

Correct Answer

verifed

verified

In the implementation of a graph, the len function returns the number of the graph's vertices.

A) True
B) False

Correct Answer

verifed

verified

Which term best describes a neighbor?


A) a path exist between vertices
B) a vertex is reachable from another vertex
C) two vertices have consecutive labels
D) two vertices are adjacent

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

Which of the following is NOT a process for which a graph can serve as a model?


A) a road map between hotels a town
B) a line at a movie theater
C) the paths that data can travel in a network
D) the routes between rooms in a building

E) B) and D)
F) A) and D)

Correct Answer

verifed

verified

B

Removing a vertex also entails removing any edges connecting it to other vertices.

A) True
B) False

Correct Answer

verifed

verified

A spanning tree has the fewest number of edges possible while still retaining a connection between all the vertices in the component.

A) True
B) False

Correct Answer

verifed

verified

A simple path in a graph is one in which a path passes through the same vertex at least twice.

A) True
B) False

Correct Answer

verifed

verified

To find the shortest path, you can use a wighted graph and sum the edge of the weights between two vertices.

A) True
B) False

Correct Answer

verifed

verified

True

The adjacency list supports finding all the vertices adjacent to a given vertex more efficiently than the adjacency matrix.

A) True
B) False

Correct Answer

verifed

verified

A a depth-first traversal cannot be implemented recursively.

A) True
B) False

Correct Answer

verifed

verified

Which of the following is true about graphs?


A) graphs consist of vertices and nodes
B) the edges between vertices are always labeled
C) an adjacency is when one vertex has a path to another vertex
D) the length of a path is the number of edges on the path

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

Showing 1 - 20 of 50

Related Exams

Show Answer