ID
int64
1
1.96k
Split
stringclasses
1 value
Domain
stringclasses
4 values
SubDomain
stringclasses
24 values
Format
stringclasses
1 value
Tag
stringclasses
2 values
Language
stringclasses
1 value
Question
stringlengths
15
717
A
stringlengths
1
292
B
stringlengths
1
232
C
stringlengths
1
217
D
stringlengths
1
192
Answer
stringclasses
4 values
Explanation
stringlengths
21
1.43k
201
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
In the preorder, inorder, and postorder sequences of a binary tree, the order of all leaf nodes is ().
All different
identical
The preorder and inorder are the same, but differ from the postorder.
In-order and post-order are the same, but different from pre-order.
B
In the three traversal methods, the order of visiting the left and right subtrees remains unchanged; only the order of visiting the root node is different. Therefore, the sequence of leaf nodes is exactly the same. Additionally, readers can use the special value method to draw a full ternary tree with three nodes and verify the correctness of the answer by applying the three traversal methods.
202
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
The number of binary trees with preorder A, B, C and postorder C, B, A is ().
1 tree
2 trees
3 trees
4 trees
D
Preorder is A, B, C, there are 5 different binary trees, among which there are 4 with postorder C, B, A (the first 4), all of which are single-branch trees.
203
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
A non-empty binary tree whose preorder traversal sequence is exactly the opposite of its postorder traversal sequence must satisfy ().
All nodes have no left child.
All nodes have no right child.
There is only one leaf node.
It is an arbitrary binary tree.
C
The preorder and postorder sequences of a non-empty tree are reversed, that is, the order of "root-left-right" is opposite to "left-right-root." Therefore, the tree has only a root node, or the root node has only a left or right subtree, and so on, with its subtrees having the same property. Consequently, all non-leaf nodes in the tree have a degree of 1, meaning the binary tree has only one leaf node.
204
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Let nodes X and Y be any two nodes in a binary tree. If in the pre-order traversal sequence of the binary tree, X comes before Y, and in the post-order traversal sequence, X comes after Y, then the relationship between X and Y is ( ).
X is the left sibling of Y.
X is the right sibling of Y.
X is an ancestor of Y.
X is a descendant of Y.
C
Assuming the preorder traversal sequence of a binary tree is NLR, and the postorder traversal sequence is LRN. According to the problem statement, X precedes Y in the preorder sequence, and X follows Y in the postorder sequence. If we assume X is at the root node position, and Y is within its left or right subtree, then the requirement is satisfied.
205
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
If the preorder sequence of nodes in a binary tree is ..a...b.., and the inorder sequence is ..b...a.., then ( )
Node a and node b are located in the left and right subtrees of a certain node, respectively.
Node b is in the right subtree of node a.
Node b is in the left subtree of node a.
Node a and node b are respectively in the two non-empty subtrees of a certain node.
C
The precedent sequence is... a... b..., indicating that b is on the left subtree of a or the left subtree of a ancestor of a in b. The middle sequence is... b... a..., indicating that B is on the left subtree of A or A is on the right subtree of B, and in summary, B is on the left subtree of A.
206
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
The possible inorder traversal sequence of a binary tree with the preorder traversal sequence of 1234567 could be ().
3124567
1234567
4135627
1463572
B
From the problem, we know that 1 is the root node, and 2 is the child of 1. For option A, 3 should be the left child of 1, and the preorder sequence should start with 13..., which is incorrect. Similarly, option C is also incorrect. For option B, 2 is the right child of 1, and 3 is the right child of 2..., which meets the requirements of the problem. For option D, 463572 should be the right subtree of 1, with 2 as the right child of 1, 46357 as the left subtree of 2, 3 as the left child of 2, 46 as the left subtree of 3, and 57 as the right subtree of 3. The preorder sequence should have 4 and 6 connected, as well as 5 and 7 connected, which is not the case.
207
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Among the following sequences, the one that cannot uniquely determine a binary tree is ().
Hierarchical sequence and inorder sequence
Preorder sequence and inorder sequence
Postorder sequence and inorder sequence
Preorder sequence and postorder sequence
D
The preorder sequence is NLR, and the postorder sequence is LRN. Although the root of the tree can be uniquely determined, it is not possible to distinguish between the left and right subtrees. For example, the preorder sequence is AB, and the postorder sequence is BA.
208
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Given that the level order sequence of a binary tree is ABCDEF and the inorder sequence is BADCFE, the preorder sequence is ().
ACBEDF
ABCDEF
BDFECA
FCEDBA
B
By constructing a binary tree, we can obtain
209
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
In a threaded binary tree, the following statement is incorrect ().
In an inorder threaded tree, if a node has a right child, its successor node is the leftmost bottom node of its right subtree.
In an inorder threaded tree, if a node has a left child, its predecessor is the rightmost bottom node of its left subtree.
Threaded binary tree is a data structure that utilizes the n+1 null pointers of a binary tree to store the information about the predecessors and successors of the nodes.
Each node can directly find its predecessor and successor through threads.
D
Not every node can directly find its predecessor and successor through threads. In a pre-order threaded binary tree, it is easy to find a node's pre-order successor, but to find the pre-order predecessor, one must know the parent node of that node. Similarly, in a post-order threaded binary tree, it is easy to find a node's post-order predecessor, but to find the post-order successor, one must also know the parent node of that node, as the binary linked list does not store pointers to parents.
210
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
The problem that still cannot be effectively solved after the binary tree is threaded is ().
Preorder Successor in Preorder Threaded Binary Tree
Inorder Successor in an Inorder Threaded Binary Tree
Inorder Threaded Binary Tree: Finding the Inorder Predecessor
Postorder Threaded Binary Tree: Finding the Postorder Successor
D
A postorder threaded binary tree cannot effectively solve the problem of finding the postorder successor. Node E's right pointer points to its right child, but in the postorder sequence, the successor of E is node B. When searching for the successor of E, the postorder threading is of no use, and one must resort to the conventional method to find it.
211
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
If the preorder sequence and the postorder sequence of a binary tree are exactly opposite, then the binary tree must be ( ).
Empty or has only one node
The height is equal to the number of its nodes.
Any node without a left child
Any node without a right child
B
The preorder and postorder sequences of a non-empty binary tree are reversed, that is, the "root-left-right" and "left-right-root" orders are opposite. Therefore, the tree has only a root node, or the root node has only a left or right subtree, and so on. Its subtrees have the same property, where any node has only one child, in order to satisfy the condition that the preorder and postorder sequences are exactly opposite. The shape of the tree should be a long chain, hence option B is selected.
212
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Among the following statements about trees, the correct one is ( ). Ⅰ. For a binary tree with n nodes, its height is log2n Ⅱ. In a complete binary tree, if a node does not have a left child, then it must be a leaf node Ⅲ. A complete binary tree with height h (h>0) corresponds to a forest containing exactly h trees Ⅳ. The number of leaves in a tree is always equal to the number of leaves in its corresponding binary tree
Ⅰ,Ⅲ
Ⅰ,Ⅱ
D
If a binary tree with n nodes is a single-branched tree, then its height is n. In a complete binary tree, there can be at most one node with degree 1, and it only has a left child. If there is no left child, then there must not be a right child either, so it must be a leaf node, so statement I is correct. Only a full binary tree possesses property II. When a tree is converted into a binary tree, if there are several leaf nodes with the same parent, after the conversion to a binary tree, there will only be one leaf node (the rightmost leaf node), so statement IV is incorrect.
213
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Let the binary tree corresponding to forest F be B, which has m nodes. The root of B is P, and the number of nodes in the right subtree of P is n. The number of nodes in the first tree of forest F is ().
m-n
m-n-1
n+1
Insufficient conditions, unable to determine
A
When converting a forest into a binary tree, the child-sibling representation is used, where the root node and its left subtree correspond to the first tree in the forest. The right subtree represents the remaining trees. Therefore, the number of nodes in the first tree is m-n.
214
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Let F be a forest, and B be a binary tree transformed from F. If there are n non-terminal nodes in F, then there are () nodes in B with an empty right pointer field.
n-1
n
n+1
n+2
C
According to the "left child right sibling" conversion rule between forests and binary trees, a right pointer field in binary tree B being empty indicates that the node has no sibling. In the forest, the root nodes of each tree, starting from the second one, are successively connected to the right child of the root of the previous tree, so the right pointer of the root node of the last tree is empty. Additionally, for each non-terminal node, the right pointer of the last child node is also empty after the conversion. Therefore, there are n+1 nodes in tree B with an empty right pointer field.
215
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Let X be a non-root node in tree T, and B be the corresponding binary tree of T. In B, X is the right child of its parent node. The correct conclusion among the following is ().
In the tree T, X is the first child of its parent node.
In the tree T, X must not have a right sibling.
In the tree T, X must be a leaf node.
In the tree T, X must have a left sibling.
D
In the binary tree B, X is the right child of its parent, so in the tree T, X must be the right nephew of its parent node; in other words, X must have a left sibling in the tree.
216
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Among the following codes, ( ) is not a prefix code.
{00,01,10,11}
{0, 1, 00, 11}
{0,10,110,111}
{10,110,1110,1111}
B
If no code is a prefix of another code, such a code is called a prefix code. In option B, 0 is the prefix of 00, and 1 is the prefix of 11.
217
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
The following statement about Huffman trees is incorrect ( )
The Huffman tree constructed for a set of weights is generally not unique.
Huffman tree has the minimum weighted path length.
There are no nodes with degree 1 in a Huffman tree.
In a Huffman tree, in addition to nodes with a degree of 1, there are also nodes with a degree of 2 and leaf nodes.
D
A Huffman tree typically refers to an extended binary tree with the minimum weighted path length. During its construction, two trees with the smallest root weights are selected each time, one as the left subtree and the other as the right subtree, to form a new binary tree. The weight of the new binary tree's root should be the sum of the weights of the root nodes of its left and right subtrees. As for which one becomes the left or right subtree, there is no restriction, so the constructed Huffman tree is not unique. Huffman trees only have nodes with degrees of 0 and 2, where nodes with degree 0 are external nodes with weights, and there are no nodes with a degree of 1.
218
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
The two core operations in a Union-Find set data structure are: ① Find, which determines whether two elements belong to the same set; ② Union, which merges two sets if the elements are not in the same set and the sets are disjoint. Assuming an initial disjoint-set of length 10 (0~9), and performing find and union operations in the sequence of 1-2, 3-4, 5-6, 7-8, 8-9, 1-8, 0-5, 1-9, the final number of sets in the disjoint-set is ().
1
2
3
4
C
Initially, 0 to 9 each form a separate set. When searching for 1-2, merge {1} and {2}; when searching for 3-4, merge {3} and {4}; when searching for 5-6, merge {5} and {6}; when searching for 7-8, merge {7} and {8}; when searching for 8-9, merge {7,8} with {9}; when searching for 1-8, merge {1,2} with {7,8,9}; when searching for 0-5, merge {0} with {5,6}; when searching for 1-9, they belong to the same set. The final sets are {0,5,6}, {1,2,7,8,9}, and {3,4}, therefore the answer is option C.
219
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Among the following descriptions of the Union-Find data structure, ( ) is incorrect.
The Union-Find set is a tree stored using the parent-pointer representation.
The Union-Find set data structure can be used to implement Kruskal's algorithm.
The Union-Find set data structure can be used to determine the connectivity of an undirected graph.
The time complexity of the find operation in a union-find set of length n is O(log2n).
D
When implementing Kruskal's algorithm to find the minimum spanning tree of a graph using a disjoint-set data structure: before deciding whether to add an edge, first check if the two vertices connected by the edge belong to the same set (i.e., determine if adding this edge would form a cycle). If it forms a cycle, then continue to evaluate the next edge; if it does not form a cycle, then add the edge and its corresponding vertices to the minimum spanning tree T, and continue to evaluate the next edge, until all vertices have been added to T. B is correct. The method to determine the connectivity of an undirected graph using a disjoint-set is to traverse the edges of the graph, and for each edge encountered, merge the two vertices it connects into the same set. After processing all edges, vertices that are connected to each other will be merged into the same subset, while vertices that are not connected will definitely be in different subsets. C is correct. A disjoint-set data structure without path compression can have a height of O(n) in the worst case, where the time complexity of the find operation is O(n), and time complexity usually refers to the worst-case time complexity. D is incorrect.
220
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is a graph?
A linear structure
A nonlinear structure with arbitrary relationships between vertices, where multiple types of relationships may exist among the vertices.
A data structure with a fixed relationship
A data structure with only a single relationship.
B
null
221
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What are the main characteristics of a graph?
The vertices in the graph have a fixed number of relationships.
The relationships between the vertices in the graph are arbitrary, and any two vertices may be related.
A graph is a data set with a fixed structure.
The vertices in the graph cannot be interconnected.
B
null
222
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
How are the numbers of predecessors and successors of the vertices in the graph constrained?
Limited to a fixed quantity
Unrestricted, can be infinite.
There can only be one predecessor and one successor.
There must be two or more predecessors and successors.
B
null
223
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is a strongly connected graph?
A directed graph in which any pair of vertices is strongly connected.
An undirected graph in which any pair of vertices is connected.
A directed graph in which there is at least one pair of vertices that are not connected.
An undirected graph in which there is at least one pair of vertices that are not connected.
A
null
224
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is the spanning tree of a connected graph?
A minimal connected subgraph containing all vertices, with n-1 edges.
A subgraph containing all vertices with n edges.
A minimal connected subgraph containing certain vertices
A non-connected subgraph containing all vertices
A
null
225
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is a simple path?
A path where vertices do not repeat
Any given path
A path that contains at least one loop.
A path where all vertices are visited more than once.
A
null
226
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is a simple cycle?
A cycle in which, except for the first and last vertices, the remaining vertices do not repeat.
A cycle that includes all vertices
A cycle that does not contain any vertices
A cycle that contains only one vertex
A
null
227
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
Which storage structures of a graph are used for undirected graphs and directed graphs, respectively?
The adjacency multilist is used for undirected graphs, while the orthogonal list is used for directed graphs.
The adjacency matrix is used for undirected graphs, while the adjacency list is used for directed graphs.
Adjacency lists are used for undirected graphs, while adjacency matrices are used for directed graphs.
Orthogonal list is used for undirected graphs, while adjacency multilist is used for directed graphs.
A
null
228
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
How is the path length defined?
The number of edges on the path
The number of vertices on the path
The distance from one vertex to another vertex.
The sum of all edge weights on the path.
A
null
229
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What are connectivity and strong connectivity?
In an undirected graph, the existence of a path between vertices is referred to as connectivity. In a directed graph, the presence of a bidirectional path between vertices is known as strong connectivity.
In an undirected graph, a bidirectional path between vertices signifies connectivity, while in a directed graph, the existence of a path between vertices indicates strong connectivity.
All vertices are mutually connected.
All vertices are not interconnected.
A
null
230
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What are subgraphs and spanning subgraphs?
A subgraph is a part of the original graph, and an induced subgraph contains all the vertices of the original graph.
A subgraph consists of a subset of all the vertices of the original graph, and an induced subgraph is a part of the original graph.
Subgraphs and spanning subgraphs both include all the vertices and edges of the original graph.
Subgraphs and induced subgraphs do not contain any vertices or edges of the original graph.
B
null
231
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is the connected component of an undirected graph?
Maximal connected subgraph in an undirected graph
Any connected subgraph in an undirected graph
Minimum connected subgraph in an undirected graph
Disconnected subgraph in an undirected graph
A
null
232
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is the strong connected component of a directed graph?
Maximal strongly connected subgraph in a directed graph
Any strongly connected subgraph in a directed graph
Strongly Connected Component (SCC) in a directed graph
Weakly connected subgraph in a directed graph
A
null
233
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is the spanning tree of a connected graph?
Minimal connected subgraph containing all vertices in the graph
Maximal connected subgraph containing part of the vertices in the graph
Any connected subgraph that includes all the vertices in the graph.
The smallest connected subgraph containing all the vertices in the graph.
A
null
234
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is a generating forest?
The set of spanning trees of connected components in a disconnected graph.
Any forest
A set consisting of multiple spanning trees
The set of all vertices and edges in a non-connected graph.
A
null
235
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is a weighted graph?
Graph with weighted edges
A graph where all edge weights are equal.
An unweighted graph
A graph with only partial edges weighted
A
null
236
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is the weighted path length?
In a weighted graph, the sum of the weights of all edges on a path.
The number of edges on the path
The number of vertices on the path
Total length of the path
A
null
237
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
In an undirected graph, if the number of vertices is n, what is the range of the number of edges?
[0, n(n-1)/2]
[0, 2n(n-1)]
[0, n]
[0, n(n+1)/2]
A
null
238
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What are sparse graphs and dense graphs?
Graphs with few edges are called sparse graphs, while those with many edges are referred to as dense graphs.
All graphs are sparse graphs.
All graphs are dense graphs.
Graphs without edges are sparse graphs, while graphs with edges are dense graphs.
A
null
239
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What are the main characteristics of the adjacency list?
Low space complexity, suitable for storing sparse graphs.
High space complexity, suitable for storing dense graphs.
The representation is unique.
Difficult to represent an undirected graph
A
null
240
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is the difference in space complexity between adjacency lists and adjacency matrices?
The space complexity of adjacency lists is low, making them suitable for sparse graphs; the space complexity of adjacency matrices is high, making them suitable for dense graphs.
The space complexity of adjacency lists is high, making them suitable for dense graphs; the space complexity of adjacency matrices is low, making them suitable for sparse graphs.
Both have the same space complexity.
Incomparable
A
null
241
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
How convenient is it to calculate the degree, in-degree, and out-degree in adjacency lists and adjacency matrices?
Using adjacency lists to calculate the degree or in-degree of a directed graph is inconvenient; with an adjacency matrix, one only needs to traverse the corresponding row or column.
Adjacency lists facilitate the calculation of degrees, in-degrees, and out-degrees; adjacency matrices are inconvenient for such calculations.
Both are convenient for calculating degree, in-degree, and out-degree.
Neither is convenient for calculating degree, in-degree, or out-degree.
A
null
242
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
How to add and remove vertices in a graph?
Use AddEdge(G, x, y) and RemoveEdge(G, x, y)
Use InsertVertex(G, x) and DeleteVertex(G, x)
Use Set_edge_value(G, x, y, v)
Use Get_edge_value(G, x, y)
B
null
243
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What are the main characteristics of Breadth-First Search (BFS)?
To find all vertices adjacent to a given vertex, an auxiliary queue is needed.
Visit each vertex only once
Recursively visit all vertices
Start visiting from the last vertex.
A
null
244
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
In breadth-first traversal, which auxiliary operations are necessary?
FirstNeighbor and NextNeighbor
AddEdge and RemoveEdge
InsertVertex and DeleteVertex
Set_edge_value and Get_edge_value
A
null
245
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
What is the time complexity of breadth-first traversal?
The time complexity for a graph stored as an adjacency matrix is O(|V|^2), while for a graph stored as an adjacency list it is O(|V| + |E|).
O(|V|)
O(|E|)
O(|V|*|E|)
A
null
246
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
Is the breadth-first spanning tree unique?
is unique
Not unique, the breadth-first spanning tree of a graph stored using an adjacency list is also not unique.
It is not unique only under certain conditions
Only in an undirected graph where it is unique
B
null
247
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
The definition of the path in the figure is ().
A sequence formed by edges consisting of vertices and ordered pairs of adjacent vertices.
A sequence formed by different vertices
Sequence formed by different edges
The above definitions are not
A
null
248
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
If an undirected graph with n vertices and e edges is a forest, then the forest must have () trees.
n
e
n-e
1
C
null
249
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
In the adjacency matrix of an undirected graph with n vertices and e edges, the number of zero elements is ().
e
2e
n^2-e
n^2 - 2e
D
null
250
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
The space used to store a graph using adjacency list method is ().
Related to the number of vertices and edges of a graph
Only related to the number of edges in the graph.
Depends only on the number of vertices of the graph.
Related to the square of the number of edges
A
null
251
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
Which description of the adjacency list is correct ().
In the adjacency list of an undirected graph, the degree of the i-th vertex is twice the number of nodes in the i-th linked list.
Adjacency lists offer more convenient operations than adjacency matrices.
Adjacency matrix operations are more convenient than adjacency list operations.
To determine the degree of nodes in a directed graph, it is necessary to traverse the entire adjacency list.
D
null
252
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
Orthogonal list is the storage structure of ().
undirected graph
Directed graph
Undirected graph and directed graph
None of them.
B
null
253
Test
Data Structure and Algorithm
Graph
Multiple-choice
Knowledge
English
The height of the breadth-first spanning tree of a graph is generally ( ) than the height of the depth-first spanning tree.
less than or equal to
less than
Greater than or equal to
Greater than
A
null
254
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
The following statement about graphs is correct ( ).
The difference between a graph and a tree is that the number of edges in a graph is greater than or equal to the number of vertices.
Assuming there is a graph G=(V, (E)), with vertex set V`⊆V and edge set E`⊆E, then V` and (E`) form a subgraph of G.
The connected components of an undirected graph refer to the maximal connected subgraphs within the undirected graph.
Graph traversal refers to the process of visiting the rest of the vertices in a graph starting from a certain vertex.
C
The difference between a graph and a tree is a logical one, not one of the number of edges; the number of edges in a graph can also be less than that in a tree, so option A is incorrect; if the edges in E' do not correspond to vertices in V', V' and (E') cannot form a graph, so option B is incorrect; the maximal connected subgraph of an undirected graph is called a connected component, so option C is correct; graph traversal requires that each node can only be visited once, and if the graph is not connected, it is not possible to visit all other vertices starting from a certain vertex, so the statement in option D is inaccurate.
255
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
The following statement about graphs is correct ( )
In a strongly connected directed graph, there is a path from any vertex to all other vertices.
The indegree of any vertex in a graph is equal to its outdegree.
A directed complete graph is necessarily a strongly connected directed clique.
The subset of the edge set and the subset of the vertex set of a directed graph can form a subgraph of the original directed graph.
C
In a strongly connected directed graph, there is a path from any vertex to all other vertices, but there may not necessarily be an arc. In an undirected graph, the indegree of any vertex is equal to its outdegree, but this may not hold for a directed graph. If a certain edge in the edge set corresponds to a vertex that is not in the corresponding vertex set, then a subset of the edge set and a subset of the vertex set cannot form a subgraph.
256
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
For a graph with n vertices: if it is a connected undirected graph, the minimum number of edges is (n-1); if it is a strongly connected directed graph, the minimum number of edges is ().
n-1, n
n-1, (n-1)
n, n
n, n(n-1)
A
For a connected undirected graph, the minimum number of edges forms a tree; for a strongly connected directed graph, the minimum number of edges forms a directed cycle.
257
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
An undirected graph G has 23 edges, 5 vertices of degree 4, 4 vertices of degree 3, and the rest are vertices of degree 2. Then, graph G has ( ) vertices:
11
12
15
16
D
In an undirected graph with n vertices and e edges, it can be determined that there are 7 vertices with a degree of 2, thus there are a total of 16 vertices.
258
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
An undirected graph with 6 vertices is guaranteed to be connected when there are () edges.
8
9
10
11
D
A complete undirected graph formed by 5 points requires 10 edges; by adding one more edge, it is ensured that the 6th vertex will necessarily form a connected graph with this complete undirected graph, thus a total of 11 edges are needed.
259
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
Regarding the storage structure of graphs, () is incorrect.
When using an adjacency matrix to store a graph, the amount of storage space used is only related to the number of vertices in the graph and is independent of the number of edges, without considering compressed storage.
Adjacency lists are used exclusively for storing directed graphs, while adjacency matrices are suitable for both directed and undirected graphs.
If the elements below the diagonal of the adjacency matrix of a directed graph are 0, then a topological ordering of the graph must exist.
The adjacency matrix of an undirected graph is symmetric, thus it is only necessary to store the lower (or upper) triangular part of the adjacency matrix.
B
A graph with n vertices, if represented by an adjacency matrix without considering compressed storage, requires O(n^2) space, which is correct for statement A. Adjacency lists can be used to store undirected graphs by treating each edge as two directed edges with opposite directions, thus needing to be stored twice, which is incorrect for statement B. Since the elements below the diagonal in the adjacency matrix are all zeros, if there is an edge <i, j>, then it must be that i<j. By transitivity, it is known that the vertex numbers in the paths of the graph are in increasing order. Assuming there is a cycle k→...→j→k, according to the problem statement, it is known that k<j<k, which is a contradiction, hence cycles do not exist, and a topological ordering must exist, making statement C correct. Option D is obviously correct.
260
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
If there is an odd number of edge nodes in the adjacency list, then ().
The graph has an odd number of nodes.
The graph has an even number of nodes.
The figure is an undirected graph.
The figure is a directed graph.
D
When an undirected graph is represented using an adjacency list, each edge is stored twice, so the number of edge list nodes is even. Since the number of edge list nodes in the problem is odd, it must be a directed graph with an odd number of edges.
261
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
Among the following statements about the breadth-first search algorithm, the correct one(s) is (are) (): Ⅰ. When all edge weights are equal, the breadth-first search algorithm can solve the single-source shortest path problem. Ⅱ. When edge weights are not equal, the breadth-first search algorithm can be used to solve the single-source shortest path problem. Ⅲ. The breadth-first traversal algorithm is similar to the post-order traversal algorithm in trees. Ⅳ. The data structure used to implement the breadth-first search algorithm for graphs is a queue.
Ⅰ,Ⅳ
Ⅱ,Ⅲ,Ⅳ
Ⅱ,Ⅳ
Ⅰ,Ⅲ,Ⅳ
A
Breadth-first search starts from the initial node and expands layer by layer to traverse the vertices of the graph, hence it cannot take into account the edge weights and is only suitable for finding the single-source shortest path in graphs with equal edge weights. Breadth-first search is equivalent to level-order traversal of a tree, III is incorrect. Breadth-first search requires a queue, while depth-first search needs a stack, IV is correct.
262
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
Undirected graph G=(V,E), where V={a,b,c,d,e}, E={(a,b),(a,e),(a,c),(b,e),(c,f),(f,d),(e,d)}. Starting from vertex a, the correct vertex sequence obtained by depth-first traversal is ().
a, b, e, c, d, f
a, c, f, e, b, d
a, e, b, c, f, d
a, e, d, f, c, b
D
Starting with a, the second traversal node is e, and the deep traversal continues, followed by d, f, c, b
263
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
Undirected graph G=(V,E), where V={a,b,c,d,e,f}, E={(a,b), (a,e),(a,c),(b,e),(c,f),(f,d),(e,d)}. The sequence that cannot be obtained by performing a depth-first traversal on this graph is ().
acfdeb
aebdfc
aedfcb
abecdf
D
Starting with a, the second traversal node is b, and the deep traversal continues, followed by e, c, d, f
264
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
Use the DFS algorithm to recursively traverse an acyclic directed graph, and output the corresponding vertices upon exiting the recursion. The resulting sequence of vertices is ( ).
Inverse topological order
Topologically ordered
unordered
None of them
A
Perform a depth-first traversal on a directed graph without specifically checking for the presence of cycles (directed loops). Regardless of whether the graph contains cycles, a sequence of vertices is obtained. If there are no cycles, the sequence output during the exit from the recursive process should be a reverse topological order. An example of topological sorting of a directed acyclic graph using depth-first search is as follows: As shown in the figure below, the order of exiting the DFS stack is efgdcahb, and one topological order of this graph is bhacdgfe. Each step of this method outputs the current node without successors first, that is, for each node v, the topological order of each of v's successors is recursively determined. For an AOV network, the sequence produced by this method is a reverse topological order.
265
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
The minimum spanning tree of any undirected connected graph ().
There is one or more
Only one
There must be multiple
It is possible that it does not exist.
A
When an undirected connected graph has multiple edges with the same weight, the minimum spanning tree may not be unique. Additionally, since this is an undirected connected graph, a minimum spanning tree must exist, hence choose A.
266
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
Among the following, the correct one is ().
As long as there are no edges with the same weight in an undirected connected graph, its minimum spanning tree is unique.
As long as there are edges with the same weight in an undirected graph, the minimum spanning tree is definitely not unique.
Selecting n-1 edges with the smallest weights from a connected graph with n vertices can form a minimum spanning tree.
Let connected graph G contain n vertices, then a subgraph with n vertices and n-1 edges must be a spanning tree of G.
A
Option A is obviously correct: For option B, if the undirected graph itself is a tree, then the minimum spanning tree is the graph itself, which in this case is unique; Option C, the selected n-1 edges may form a cycle; Option D, a subgraph with n vertices and n-1 edges may form a cycle or may be disconnected.
267
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
The correct statement among the following is ().
The shortest path must be a simple path.
The Dijkstra algorithm is not suitable for finding the shortest path in weighted graphs with cycles.
The Dijkstra algorithm is not suitable for finding the shortest path between any two vertices.
When the Floyd algorithm is used to find the shortest path between two vertices, path_(k-1) is necessarily a subset of path_k.
A
Option A is correct. The Dijkstra algorithm is suitable for finding the shortest path in a weighted graph with cycles and can also find the shortest path between any two vertices. However, it is not suitable for shortest path problems with negative weights. When using the Floyd algorithm to find the shortest path between two vertices, if the shortest path changes, then path_k-1 is not a subset of path_k.
268
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
The following methods can be used to determine whether a directed graph contains a cycle is (): Ⅰ. Depth-first traversal Ⅱ. Topological sorting Ⅲ. Finding the shortest path Ⅳ. Finding the critical path
Ⅰ,Ⅱ,Ⅳ
Ⅰ,Ⅲ,Ⅳ
Ⅰ,Ⅱ,Ⅲ
All possible
A
Using depth-first traversal, if starting from a vertex u on a directed graph, an edge from vertex v to u appears before the end of DFS(u), since v is a descendant of u in the spanning tree, there must be a cycle in the graph that includes both u and v. Therefore, depth-first traversal can detect whether a directed graph has a cycle. During topological sorting, a vertex can only be added to the sequence when it is not the head of any edge. If there is a cycle, the vertices in the cycle are always the head of some edge and cannot be added to the topological sequence. In other words, if there are still vertices that cannot be found to be added to the topological sequence, it indicates that the graph has a cycle. Finding the shortest path allows the graph to have cycles. As for whether the critical path can determine if a graph has a cycle, there is some controversy. Although the critical path itself does not allow cycles, the algorithm for finding the critical path cannot determine whether there are cycles. Determining whether there are cycles is the first step in finding the critical path—topological sorting. Therefore, the answer to this question mainly depends on the perspective from which you approach the problem. Candidates need to understand the issue itself, as the real unified examination will not involve such ambiguous questions.
269
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
In the topological ordering of the directed graph G, if vertex V_i precedes vertex V_j, then the following situation cannot occur: ()
G contains an arc <V_i, V_j>.
There is a path from V_i to V_j in G.
There is no arc <V_i, V_j> in G.
There is a path from V_j to V_i in G.
D
If there exists a path from V_j to V_i in graph G, indicating that V_j is a predecessor of V_i, then V_j must be removed before V_i can be removed, thus in the topological sequence V_j must be output before V_i, which is clearly contradictory to the problem statement.
270
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
If the vertices of a directed graph cannot be arranged in a topological order, then it can be determined that the directed graph ().
It is a rooted directed graph.
It is a strongly connected graph.
Containing multiple vertices with an indegree of 0
Strongly connected components with more than one vertex
D
If a topological sort does not exist, it indicates that there must be a cycle in the graph, which forms a strongly connected component (it is not difficult to understand that a strongly connected component with more than one vertex must contain a cycle).
271
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
The following statements about topological sorting are incorrect (). Ⅰ. If a directed graph has a cycle, then the directed graph definitely does not have a topological sort. Ⅱ. In the topological sorting algorithm, to temporarily store vertices with an in-degree of zero, a stack or a queue can be used. Ⅲ. If the topological order sequence of a directed graph is unique, then the in-degree and out-degree of each vertex in the graph are at most 1.
Ⅰ,Ⅲ
Ⅱ,Ⅲ
D
In Ⅰ, for a directed graph that contains cycles, running the topological sorting algorithm will inevitably result in a subgraph with cycles where no nodes with an indegree of 0 can be found, thus preventing the continuation of the topological sort. In Ⅱ, note that if there is no ancestor or descendant relationship between two nodes, their order in the topological sequence is arbitrary (i.e., their precedence is arbitrary), so both stacks and queues can be used, as the nodes entering the stack or queue have an indegree of 0, and at this point, all nodes with an indegree of 0 are unrelated. Ⅲ is the challenging part; if the topological order sequence is unique, it naturally leads one to think of a linear directed graph (which is incorrect).
272
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
If the vertices of a directed graph cannot be arranged into a topological order, then it is determined that the directed graph ( )
Containing multiple vertices with an out-degree of 0
It is a strongly connected graph.
Vertices with multiple indegrees of 0
Strongly connected components with more than one vertex
D
If the vertices of a directed graph cannot be arranged into a topological sequence, it indicates that there is a cycle with more than one vertex within the graph. This cycle forms a strongly connected component, therefore the answer is D.
273
Test
Data Structure and Algorithm
Graph
Multiple-choice
Reasoning
English
If a directed graph has an ordered topological sorting sequence, then its adjacency matrix must be ().
Symmetry
Sparse
Triangle
General
C
It can be proven that a necessary and sufficient condition for properly numbering the vertices of a directed graph so that its adjacency matrix is a triangular matrix with all diagonal elements being zero is that the directed graph can be topologically sorted. If the term "ordered" is removed from the problem, the obvious choice would be D. However, the stem of the question has already specified an "ordered topological sequence," so the correct choice should be C. It is important to note that if the adjacency matrix of a directed graph is a triangular matrix (with zero elements on the diagonal), then the graph must not contain any cycles, and therefore a topological sequence must exist.
274
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
In which scenarios are static search tables and dynamic search tables respectively applicable?
Static search tables are suitable for lookup operations only, while dynamic search tables are suitable for extensive insert and delete operations.
Dynamic search tables are suitable for lookup operations only, while static search tables are suitable for a large number of insert and delete operations.
Both are suitable for performing a large number of insertions and deletions.
Both are only applicable to search operations.
A
null
275
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What are the main characteristics of static and dynamic search tables?
Static search tables do not allow insertion and deletion, while dynamic search tables allow for insertion and deletion.
Static and dynamic search tables both do not allow insertion and deletion.
Static and dynamic search tables both allow for insertion and deletion.
Static search tables allow insertion and deletion, while dynamic search tables do not.
A
null
276
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What is the basic idea of sequential search?
Sequentially search from beginning to end or from end to beginning.
Random Access of Elements
Only search for the first element of the array.
Use binary search method
A
null
277
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
In the implementation of sequential search, what is returned if the search is successful?
array index
-1
The value of the element found
Search Time Required
A
null
278
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
In the sentinel method of sequential search, what is returned when the search is successful?
Array index
-1
The value of the element found
Search Time Required
A
null
279
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
In binary search, how is the interval for the next search determined?
Based on the comparison between the middle element and the element to be found, choose either the first half or the second half to continue the search.
Always choose the first half to continue the search.
Always choose the latter half to continue the search.
Randomly select either the first half or the second half to continue the search.
A
null
280
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What are the characteristics of the decision tree for binary search?
Balanced binary tree with only the bottom level not full.
Full binary tree
Unbalanced binary tree
Any form of binary tree
A
null
281
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
In block search, what methods can be used to locate the block containing the target keyword?
Sequential Search and Binary Search
Sequential Search and Hash Search
Binary Search and Hash Search
Can only use sequential search.
A
null
282
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What should be the block size when the Average Search Length (ASL) of a block search is minimized?
Equal to the square root of the lookup table length
Equal to the length of the lookup table
Equal to half the length of the lookup table.
Independent of the lookup table length
A
null
283
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
In block search, what are the average search lengths (ASL) when using sequential search and binary search to look up the index table?
The ASL (Average Search Length) for sequential search is (s^2 + 2s + n) / (2s), and the ASL for binary search is (S + 1) / 2 + ⌈log2(b+1)⌉.
The ASL (Average Search Length) for sequential search is (S+1)/2, and for binary search is (s^2+2s+n)/(2s).
Both have the same ASL (Arithmetic Shift Left).
Incomparable
A
null
284
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What is the range of the number of subtrees and the number of keys in a node of an m-order B-tree?
The number of subtrees ∈ [⌈m/2⌉, m], the number of keys ∈ [⌈m/2⌉-1, m-1].
Number of subtrees ∈ [2, m], number of keys ∈ [1, m-1]
Number of subtrees ∈ [1, m-1], number of keys ∈ [0, m-2]
The number of subtrees and the number of keywords are not limited.
B
null
285
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What is the range of heights for an m-order B-tree with n keys?
logm(n+1) ≤ h ≤ log⌈m/2⌉((n+1)/2) + 1
h = m
h = n
The height of a B-tree is not fixed.
A
null
286
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What are the characteristics of the keys in a B-tree?
Subtree0 < Key1 < Subtree1 < Key2 < Subtree2 <…
All keywords are equal.
All keywords are distinct but unordered.
Keywords Random Distribution
A
null
287
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What are the basic operations involved in the search process of a B-tree?
First, locate the node in the B-tree, then find the key within the node.
Search for the key directly in the root node of the B-tree.
First, find the keyword in the leaf nodes, then search upwards.
Randomly select a node to search.
A
null
288
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
When inserting a key into a B-tree, if the number of keys in the node exceeds the upper limit after insertion, what should be done?
Directly delete certain keywords
Split the node from the middle into two nodes.
Move the keyword to the parent node.
Change the order of the B-tree
B
null
289
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
How should it be handled when deleting a terminal node in a B-tree if the number of keys in the node is less than ⌈m/2⌉?
Directly delete the keyword
Adjust nodes to achieve a new balance.
Merge nodes
Modifying the Structure of a B-Tree
C
null
290
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
How should one operate when deleting a non-leaf node key in a B-tree?
Use direct predecessor or direct successor to replace the deleted key.
Directly delete the keyword
Modify the structure of the B-tree
Adjust nodes to achieve a new balance.
A
null
291
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What principle is hash search based on?
Directly mapping keywords to addresses.
Sequential Search
Binary Search
Block Search
A
null
292
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What is the reason for choosing p in the modulus reservation method?
Ensure that the keywords are mapped to any address in the hash space with equal probability after being transformed by the hash function.
p is a fixed constant.
Reduce computation time
Concentrate hash addresses
A
null
293
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
How does open addressing resolve hash collisions?
Store by finding a free hash address.
Store conflicting elements outside the hash table.
Change the hash function
Reorganize the elements in the hash table
A
null
294
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What problems might linear probing cause?
A large number of elements accumulate at adjacent hash addresses.
The length of the hash table must be a prime number.
No need to mark when deleting elements.
Potential detection of all positions
A
null
295
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
What conditions must the length of the hash table satisfy for quadratic probing?
is any prime number
is any integer
Prime numbers of the form 4k+3
No special requirements.
C
null
296
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
In which scenarios is the chaining method applicable?
Frequent insertions and deletions
The length of the hash table is relatively short.
The distribution of keywords is very uniform.
The data volume is very large.
A
null
297
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
Sequential search is suitable for linear lists with a () storage structure.
Sequential storage structure or linked storage structure
Hash storage structure
Index storage structure
Compressed storage structure
A
null
298
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
When using block search, the data is organized in the following way: ( )
The data is divided into several blocks, with the data within each block being ordered.
The data is divided into several blocks, where the data within each block does not need to be ordered, but the blocks themselves must be in order. The maximum (or minimum) data within each block forms the index block.
The data is divided into several blocks, with the data within each block being ordered. The maximum (or minimum) data within each block forms the index block.
The data is divided into several blocks, with each block (except for the last one) containing an equal number of data points.
B
null
299
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
The efficiency of searching in a binary search tree is related to the () of the tree.
Depth of a binary sort tree
The number of nodes in a binary sort tree
Degree of the node being searched
Binary Sort Tree Storage Structure
A
null
300
Test
Data Structure and Algorithm
Searching
Multiple-choice
Knowledge
English
In the commonly used storage structure for describing binary sort trees, the node with the largest key value is ().
The left pointer must be null.
The right pointer must be null.
Both left and right pointers are null.
Both the left and right pointers are not null.
B
null