Exam Prep - Graph Implementations Chapter.30 - Data Structures with Java 5e Complete Test Bank by Frank M. Carrano. DOCX document preview.
Chapter 30 - Graph Implementations
True/False (10)
- An undirected graph is symmetric.
- In an unweighted graph represented by an adjacency matrix, you cannot use boolean values.
- An adjacency matrix occupies a fixed amount of space dependent on the number of edges in the graph.
- In an adjacency list, space is not reserved for edges that do not exist.
- An adjacency matrix uses less memory than an adjacency list.
- For a dense graph, using an adjacency matrix to represent the graph is a better choice.
- Regardless of how you implement a graph, you need a container such as a dictionary for the graph’s vertices.
- Using an adjacency list, you might need to search the entire list to determine if an edge exists between any two given vertices.
- An adjacency matrix uses less space for a sparse graph than an adjacency list.
- Using an adjacency matrix, you can use an edge weight of infinity to represent that there is no edge between any two given vertices.
Short Answer (5)
- Fill in the adjacency matrix for the following graph.
X | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
0 | ||||||||||
1 | ||||||||||
2 | ||||||||||
3 | ||||||||||
4 | ||||||||||
5 | ||||||||||
6 | ||||||||||
7 | ||||||||||
8 | ||||||||||
9 |
X | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
2 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
3 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
4 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
6 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
7 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 1 |
8 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 |
9 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
- Fill in the adjacency matrix for the following graph.
X | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
0 | ||||||||
1 | ||||||||
2 | ||||||||
3 | ||||||||
4 | ||||||||
5 | ||||||||
6 | ||||||||
7 |
X | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 |
1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
2 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
3 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
5 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 |
6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
7 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
- Explain the steps to add an edge to the ADT DirectedGraph.
- In the ADT DirectedGraph, what is the purpose of the data fields visited, previousVertex and cost?
- Explain why we use an inner class Edge even if there is no weight associated with edges.
Multiple Choice (19) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED WITH . YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.
- A common implementation of a graph that uses a two dimensional array to represent the graph’s edges is called a(n)
- adjacency matrix
- graph array
- adjacency array
- adjacency list
- A common implementation of a graph that uses a list to represent the graph’s edges is called a(n)
- adjacency list
- adjacency matrix
- graph list
- array list
- In an adjacency matrix, each row and each column corresponds to
- a vertex in the graph
- an edge in the graph
- both a & b
- none of the above
- What type of values are typically stores in unweighted graphs?
- boolean
- integers
- 0 and 1
- strings
- The adjacency matrix for an undirected graph is
- symmetric
- asymmetric
- weighted
- irregular
- In a graph represented by an adjacency matrix, you can determine if an edge exists between any two given vertices in _____ operations.
- O(1)
- O(n)
- O(log n)
- O(n2)
- In a graph represented by an adjacency matrix, you can find all the neighbors of a given vertices in _____ operations.
- O(n)
- O(1)
- O(log n)
- O(n2)
- An adjacency matrix occupies
- a fixed amount of space dependent on the number of vertices in the graph
- a fixed amount of space dependent on the number of edges in the graph
- a variable amount of space dependent on the number of vertices in the graph
- a variable amount of space dependent on the number of edges in the graph
- For a sparse graph, an adjacency list uses _____ memory than an adjacency matrix.
- less
- more
- the same amount of
- none of the above
- Each vertex in a graph of n vertices can be the origin of at most _____ edges.
- n – 1
- n + 1
- n
- 1
- In the interface VertexInterface, the connect methods
- connect two vertices
- connect two edges
- connect two graphs
- none of the above
- In the interface VertexInterface, the connect methods require _____ operations.
- O(n)
- O(1)
- O(log n)
- O(n2)
- In the ADT graph, the method addVertex has efficiency
- O(n)
- O(log n)
- O(n2)
- O(1)
- In the ADT graph, the method addEdge has efficiency
- O(n)
- O(log n)
- O(n2)
- O(1)
- In the ADT graph, the method hasEdge has efficiency
- O(n)
- O(log n)
- O(n2)
- O(1)
- In the ADT graph, the method isEmpty has efficiency
- O(1)
- O(log n)
- O(n2)
- O(n)
- In the ADT graph, the method getNumberOfVertices has efficiency
- O(1)
- O(log n)
- O(n2)
- O(n)
- In the ADT graph, the method getNumberOfEdges has efficiency
- O(1)
- O(log n)
- O(n2)
- O(n)
- In the ADT graph, the method clear has efficiency
- O(1)
- O(log n)
- O(n2)
- O(n)
Document Information
Connected Book
Data Structures with Java 5e Complete Test Bank
By Frank M. Carrano
Test Bank
General
View Product →
Explore recommendations drawn directly from what you're reading
Quick Navigation
Benefits
Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party