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
101
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
What are the common storage methods for sparse matrices?
Use a standard two-dimensional array.
Store only non-zero elements
Use linked lists to store non-zero elements.
Use special data structures such as triple tables or orthogonal lists.
D
null
102
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
A binary linked list, also known as a binary tree linked list, can be used to represent a binary tree.
Left-child right-sibling representation, used to represent trees or forests.
Right-child left-sibling representation, used to represent a graph.
Left-child right-sibling representation, used to represent queues.
Right-child left-sibling representation, used to represent a stack.
A
null
103
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
Stacks and queues have the same ().
Abstract Data Type
Logical Structure
Storage Structure
operation
B
null
104
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
A stack is ( ).
Sequential storage of linear structure
Non-linear structure stored in the chained storage formula
Linear structure of restricted access points
Nonlinear structure with constrained storage points
C
null
105
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
() is not a basic operation of a stack.
Pop the top element from the stack.
Remove the bottom element of the stack.
Determine if the stack is empty.
Empty the stack.
B
null
106
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
The benefits of using a shared stack are ().
Reduce access time and decrease the likelihood of overflow.
Save storage space to reduce the likelihood of overflow.
Reduce access time and decrease the likelihood of underflow.
Save storage space, reduce the likelihood of underflow.
B
null
107
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
The permitted operations on the queue are ().
Sort the elements in the queue.
Remove the most recently enqueued element.
Insert elements between queue elements
Delete the front element
D
null
108
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
Given that the storage space for a circular queue is the array A[21], with front pointing to the position before the head element and rear pointing to the tail element, assuming the current values of front and rear are 8 and 3, respectively, the length of the queue is ().
5
6
16
17
C
null
109
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
The following () involves the use of a queue.
Parentheses Matching
Maze Solving
Page Replacement Algorithm
Recursion
C
null
110
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
The main purpose of using compressed storage for special matrices is to ().
Expression becomes simplified.
Access to matrix elements becomes simple.
Remove redundant elements from the matrix
Reduce unnecessary storage space
D
null
111
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
When compressing a symmetric matrix, a sequential list of length () is required.
n/2
n*n/2
n(n + 1)/2
n(n-1)/2
C
null
112
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Knowledge
English
In a two-dimensional array A, assuming each array element occupies 3 storage units, with row index i ranging from 0 to 8 and column index j ranging from 0 to 9, and the elements are stored continuously starting from the base address SA. Under these circumstances, the starting address of the element A[8][5] is ().
SA+141
SA+144
SA+222
SA+255
D
null
113
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
Assuming an array a[n] is used to sequentially store a stack, with 'top' representing the stack top pointer, and 'top == -1' indicating the stack is empty, and knowing the stack is not full, the operation performed when element x is pushed onto the stack is ().
a[--top] = x
Pop the element x into the array a at the position indicated by top, then decrement top.
a[++top] = x
a[top++] = x
C
Initially, when top is -1, after the first element is pushed onto the stack, top becomes 0, which points to the top element of the stack. Therefore, when pushing an element onto the stack, the pointer top should be incremented by 1 first, and then the element should be pushed onto the stack. Only option C conforms to the meaning of the question.
114
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
Assuming a linked list without a head node and all operations are performed at the head of the list, the least suitable option to serve as a linked stack is ().
A doubly circular linked list with only a head pointer and no tail pointer.
A doubly circular linked list with only a tail pointer and no head pointer.
A singly circular linked list with only a head node pointer and no tail node pointer.
A singly circular linked list with only a tail pointer and no head pointer.
C
For a doubly linked list, whether it is the head pointer or the tail pointer, it is very convenient to find the head node, which facilitates insertion or deletion operations at the head. In a singly linked list, the head node can be easily found through the tail pointer, but finding the tail node through the head pointer requires traversing the list once. For C, after inserting or deleting a node, finding the tail node takes O(n) time.
115
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
To perform the Pop operation on a linked stack (without a head node) and store the popped element in X, the following steps should be executed ().
x=top; top=top->next
x = top->data
top = top->next; x = top->data
x = top->data; top = top->next
D
Assuming the top pointer refers to the top element of the stack, option D is selected; in option A, the top pointer is incorrectly assigned to x. Option B does not modify the value of the top pointer; option C is the answer when the top pointer points to the element above the top element of the stack.
116
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
Given that a, b, c, d, e, f are pushed onto the stack in the given order, if pop operations are allowed during the push operations, the sequence that cannot be obtained is ().
fedcba
bcafed
dcefba
cabdef
D
According to the "last in, first out" characteristic of a stack, and allowing pop operations while pushing, it is obvious that case D will be the first to be popped out.
117
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
If the input sequence of a stack is 1, 2, 3, ..., n, and the first element of the output sequence is n, then the i-th output element is ().
Uncertain
n-i
n-i-1
n-i+1
D
The nth element is the first to be popped, indicating that the previous n-1 elements have already been pushed onto the stack in order. Given the "last in, first out" characteristic, it is certain that the output sequence at this point must be the reverse of the input sequence. Therefore, the answer is D.
118
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
The input sequence of a stack is 1, 2, 3, ..., n, and if the first element of the output sequence is i, then the j-th output element is ().
i-j-1
i-j
j - i + 1
Uncertain
D
When the ith element is the first to be popped, the elements before it can be popped in sequence after i, but the remaining elements can be pushed onto the stack at this time and will also be popped before the elements preceding i, so the jth element to be popped is uncertain.
119
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
The input sequence for a certain stack is a, b, c, d. Among the following 4 sequences, the one that cannot be its output sequence is ().
a, b, c, d
c, b, d, a
d, c, a, b
a, c, b, d
C
For A, the possible sequence is: a in, a out, b in, b out, c in, c out, d in, d out. For B, the possible sequence is: a in, b in, c in, c out, b out, d in, d out, a out. For D, the possible sequence is: a in, a out, b in, c in, c out, b out, d in, d out. C does not have a corresponding sequence.
120
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
If the input sequence of a stack is P_1, P_2, P_3, P_4, and the output sequence is 1, 2, 3, ..., n, if P_3 = 1, then the value of P_1 is ().
It might be 2.
It must be 2.
It cannot be 2.
It cannot be 3.
C
The push sequence is P_1, P_2, ..., P_n. Since P_3 = 1, that is, P_1, P_2, P_3 are pushed onto the stack consecutively, and the first element to be popped is P_3, it indicates that P_1 and P_2 have already been pushed onto the stack in order. According to the Last In, First Out (LIFO) principle, it is known that P_2 must be popped before P_1. Since the second element to be popped is 2, and at this time P_1 is not the top element of the stack, therefore the value of P_1 cannot be 2.
121
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
Given that the push sequence of a stack is 1, 2, 3, 4, and the pop sequence is P_1, P_2, P_3, P_4, then P_2, P_4 cannot be ().
2,4
2,1
4,3
3,4
C
Evaluate the possible push and pop sequences for each option. For A, the possible sequence is: push 1, pop 1, push 2, pop 2, push 3, pop 3, push 4, pop 4. For B, the possible sequence is: push 1, push 2, push 3, pop 3, pop 2, push 4, pop 4, pop 1. For D, the possible sequence is: push 1, pop 1, push 2, push 3, pop 3, pop 2, push 4, pop 4. C does not have a corresponding sequence because when 4 is in the stack, it means that all previous elements (1, 2, 3) have been in the stack or have been pushed before. If 4 is the second to be popped, there are still two elements in the stack, which are ordered (according to the push sequence), and can only be (1,2), (1,3), or (2,3). If it is the sequence (1,2), then 2 and 3 have already been pushed and cannot be popped later. If it is either (1,3) or (2,3), then 3 must be the next element to be popped, meaning p3 must be 3, so P4 cannot be 3.
122
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
Assuming the initial state of the stack is empty, when the character sequence "n1_" is input into the stack, there are ( ) sequences of length 3 that can be used as C language identifiers.
4
5
3
6
C
Identifiers can only start with an English letter or an underscore, not with a digit. Therefore, an identifier composed of the characters n, 1, and _ can be arranged in four ways: n1_, n_1, _1n, and _n1. For the first case, n is pushed onto the stack and then popped, 1 is pushed onto the stack and then popped, and _ is pushed onto the stack and then popped. For the second case: n is pushed onto the stack and then popped, 1 is pushed onto the stack, _ is pushed onto the stack, _ is popped, and then 1 is popped. For the third case: n is pushed onto the stack, 1 is pushed onto the stack, _ is pushed onto the stack, _ is popped, 1 is popped, and then n is popped. However, according to the characteristics of stack operations, the case of _n1 is not possible, therefore the answer is C.
123
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
The enqueuing order of a queue is 1, 2, 3, 4, then the dequeuing output order is ().
4, 3, 2, 1
1,2,3,4
1,4,3,2
3, 2, 4, 1
B
The order of enqueuing and dequeuing in a queue is consistent, which is different from a stack.
124
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
If a circular queue is implemented with the array A[0...5], and the current values of rear and front are 1 and 5 respectively, after deleting one element from the queue and adding two elements, the values of rear and front will be ().
3 and 4
3 and 0
5 and 0
5 and 1
B
In a circular queue, each time an element is deleted, the front pointer is updated as front = (front + 1) % 6, and each time an element is inserted, the rear pointer is updated as rear = (rear + 1) % 6. After the aforementioned operations, front = 0, rear = 3.
125
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
Assuming a circular queue Q[MaxSize] with the head pointer as front and the tail pointer as rear, and the maximum capacity of the queue is MaxSize, without any other data members, the condition for the queue being full is ().
Q.front == Q.rear
If Q.front + Q.rear >= Maxsize
Q.front == (Q.rear + 1) % MaxSize
Q.rear == (Q.front + 1) % Maxsize
C
Since no additional data members can be added, the only method to distinguish between an empty queue and a full queue is to sacrifice one storage unit. It is agreed that "the queue is full when the front pointer is at the position right after the rear pointer," hence option C is selected. Option A is the condition for determining if the queue is empty, while options B and D are distractors.
126
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
If 1, 2, 3, 4 are used as the input sequence for a double-ended queue, the output sequence that cannot be obtained by either an input-restricted double-ended queue or an output-restricted double-ended queue is ().
1, 2, 3, 4
4, 1, 3, 2
4, 2, 3, 1
4, 2, 1, 3
C
Use the elimination method. First, consider the sequences that can be generated by a double-ended queue with input restrictions: assume the right end is input-restricted, and 1, 2, 3, 4 are inserted from the left in order, then by extracting from the left in order we get 4, 3, 2, 1, which eliminates option A; by extracting right, left, right, right, we get 4, 1, 3, 2, which eliminates option B; next, consider the sequences that can be generated by a double-ended queue with output restrictions: assume the right end is output-restricted, and 1, 2, 3, 4 are inserted left, left, right, left, then by extracting from the left in order we get 4, 2, 1, 3, which eliminates option D.
127
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
The postfix expression for the expression a*(b+c)-d is ().
abcd*+-
abc+*d-
abc*+d-
-+*abcd
B
In postfix notation, each operator is placed directly after its two operands, and each expression is transformed step by step according to the precedence of operations to obtain the postfix expression.
128
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
When using a stack to calculate the value of an expression, suppose there is an operand stack named OPEN with only two storage units. The expression that will not cause an overflow is ().
A-B*(C-D)
(A-B)*C-D
(A-B*C)-D
(A-B) * (C-D)
B
When using a stack to calculate the value of an expression, separate operator and operand stacks can be established without changing the underlying principle. In option B, A is pushed onto the stack followed by B, resulting in R1 after calculation. C is then pushed onto the stack, resulting in R2 after calculation. D is pushed onto the stack, resulting in R3 after calculation, which leads to a stack depth of 2. Calculating A, C, and D in sequence results in stack depths of 4, 3, and 3, respectively. Therefore, option B is chosen.
129
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
After executing the following segment of code, the value of i is ( ). int f(int x){ return ((x>0)? x*f(x-1):2); } int i; i=f(f(1));
2
4
8
Infinite recursion
B
Stacks and recursion are closely related. The recursive model includes two aspects: the base case and the recursive case. The base case is the exit of the recursive algorithm, that is, the condition to terminate the recursion. The recursive case is a recursive relation. According to the problem, we have f(0)=2; f(1)=1*f(0)=2; f(f(1))=f(2)=2*f(1)=4; Thus, f(f(1))=4. Therefore, the answer to this question is B.
130
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
For the recursive algorithm solution to a problem and its corresponding non-recursive algorithm solution, ().
Recursive algorithms are often more efficient.
Non-recursive algorithms are generally more efficient.
Both are the same.
Incomparable
B
Under normal circumstances, recursive algorithms often involve a lot of redundant computations when actually executed by a computer, which can result in low efficiency.
131
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
When performing the () operation, it is necessary to use a queue as auxiliary storage space.
Search hash table
Breadth-First Search (BFS) Graph
Preorder (Root) Traversal of a Binary Tree
Depth-First Search Graph
B
This question involves the content of Chapter 5 and Chapter 6. The breadth-first search of a graph is similar to the level-order traversal of a tree, both of which require the use of a queue.
132
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
Among the following statements, the correct one is ().
Eliminating recursion does not necessarily require the use of a stack.
For the same input sequence, two sets of different valid push and pop combination operations will always result in the same output sequence.
Queues are commonly used to handle function or procedure calls.
Queues and stacks are linear lists with restricted operations, allowing operations only at the two ends of the list.
A
Eliminating recursion does not necessarily require the use of a stack.
133
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
Given an n*n symmetric matrix A, its lower triangular part is stored in a one-dimensional array B in a row-wise manner, with A[0][0] being stored at B[0]. Then, the diagonal element A[i][i] of the (i+1)th row is stored at the position () in B.
(i+3)i/2
(i + 1)i/2
(2n-i+1)i/2
(2n - i - 1)i / 2
A
This question requires attention to three details: the minimum index of the matrix is 0; array indices also start from 0; the matrix is stored in the array in row-major order. Keeping these three points in mind, the answer is not difficult to obtain, which is A. Moreover, it is recommended to use the method of substituting special values to solve such problems. For example, the corresponding index for A[1][1] should be 2, and after substitution, only A satisfies the condition.
134
Test
Data Structure and Algorithm
Stack, Queue, and Array
Multiple-choice
Reasoning
English
If an n-th order lower triangular matrix A is compressed and stored in a one-dimensional array B[1...n(n+1)/2+1] in column-major order, then the relationship between the indices i, j of the non-zero element a_i,j (1≤i,j≤n) stored in B[k] and k is ().
(j-1)(2n-j+1)/2 + i - j
(j - 1)(2n - j + 2)/2 + i - j + 1
(j - 1)(2n - j + 2)/2 + i - j
(j - 1)(2n - j + 1)/2 + i - j - 1
B
In column-major order storage, there are j-1 columns before the element a_i,j, with a total of n+(n-1)+...+(n-j+2)=(j-1)(2n-j+2)/2 elements. The element a_i,j is the (i-j+1)th element in the jth column. The array B starts indexing from 1, so k= (j-1)(2n-j+2)/2+i-j+1.
135
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is a string?
A finite sequence of arbitrary characters
A sequence consisting solely of numbers
A sequence consisting solely of special symbols
A sequence of space characters
A
null
136
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What does the length of a string refer to?
Total number of characters in the string
The number of space characters in a string
The number of special characters in the string
The number of numeric characters in a string
A
null
137
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the difference between an empty string and a blank string?
The empty string contains no characters, while the space string contains space characters.
Both the empty string and the space string contain no characters.
The empty string contains the space character, while the space string contains no characters.
The empty string and the blank string are of the same type of string.
A
null
138
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the relationship between a substring and a main string?
A substring is a sequence of consecutive characters in a main string.
Substrings and main strings are completely different.
Substring contains main string
A substring is longer than the main string.
A
null
139
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the relationship between strings and linear lists?
A string is a special kind of linear list.
Strings and linear lists are completely different.
Strings are a subset of linear lists.
A string is a superset of a linear list.
A
null
140
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
Why is the data object of a string limited?
Character set
Number set
Special Symbol Set
Graphic Symbol Set
A
null
141
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What are the basic operations on strings usually performed on?
substring
The entire string
single character in a string
specific part of a string
A
null
142
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is a string name?
String Identifier
The length of a string
Reference name of a string
String type
A
null
143
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is an empty string?
The string does not contain any characters.
The string contains only space characters.
The length of the string is 0.
The string contains only special characters.
A
null
144
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What are the characteristics of strings as linear lists?
The data elements exhibit a linear relationship.
The data elements are uncorrelated.
The relationship between data elements is nonlinear.
Random association between data elements
A
null
145
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the function of the StrAssign operation?
Assign one string to another string.
Duplicate a string
Concatenate two strings
Empty a string
A
null
146
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the purpose of the StrLength operation?
Check if the string is empty
Destroy a string
Compare two strings
Find the length of the string.
D
null
147
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the function of the ClearString operation?
Concatenate two strings
Find the substring
Empty a string
Determine the position of the substring in the main string.
C
null
148
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the Concat operation used for?
Concatenate two strings
Find the substring
Empty a string
Find the position of the substring in the main string.
A
null
149
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the purpose of the SubString operation?
Determine the position of the substring in the main string.
Concatenate two strings
Destroy a string
Retrieve a specific substring from the main string.
D
null
150
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the StrCompare operation used for?
Find the position of the substring in the main string.
Concatenate two strings
Destroy a string
Compare two strings
D
null
151
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the basic process of the naive pattern matching algorithm?
Compare all characters at once
Compare characters one by one; if a mismatch occurs, both the main string and pattern string pointers backtrack.
Only compare the first character of the main string and the pattern string.
Use a hash function to compare the main string and the pattern string.
B
null
152
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the worst-case time complexity of the naive pattern matching algorithm?
O(n)
O(nm)
O(m)
O(n+m)
B
null
153
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the function of the next array in the KMP algorithm?
Record the frequency of each character in the pattern string.
Indicate the position of each character in the pattern string.
When the pattern string mismatches, it indicates the starting position for the next match.
Store the index of each character in the main string.
C
null
154
Test
Data Structure and Algorithm
String
Multiple-choice
Knowledge
English
What is the method for computing the next array in the KMP algorithm?
According to the frequency of characters in the pattern string
According to the length of the repeated substring in the pattern string
Starting from the third character of the pattern string, compare and adjust based on the previous character.
Compare each character in the main string and the pattern string.
C
null
155
Test
Data Structure and Algorithm
String
Multiple-choice
Reasoning
English
The next array values for the string 'ababaaababaa' are ().
01234567899
012121111212
011234223456
0123012322345
C
The calculation process is as follows| index | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |------|----|----|----|----|----|----|----|----|----|----|----|----| | S | a | b | a | b | a | a | a | b | a | b | a | a | | PM | 0 | 0 | 1 | 2 | 3 | 1 | 1 | 2 | 3 | 4 | 5 | 6 | | next | 0 | 1 | 1 | 2 | 3 | 4 | 2 | 2 | 3 | 4 | 5 | 6 |
156
Test
Data Structure and Algorithm
String
Multiple-choice
Reasoning
English
The next array for the string 'ababaaababaa' is ().
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8
-1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1
-1, 0, 0, 1, 2, 3, 1, 1, 2, 3, 4, 5
-1, 0, 1, 2, -1, 0, 1, 2, 1, 1, 2, 3
C
The calculation process is as follows| index | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |------|----|----|----|----|----|----|----|----|----|----|----|----| | S | a | b | a | b | a | a | a | b | a | b | a | a | | PM | 0 | 0 | 1 | 2 | 3 | 1 | 1 | 2 | 3 | 4 | 5 | 6 | | next | -1 | 0 | 0 | 1 | 2 | 3 | 1 | 1 | 2 | 3 | 4 | 5 |
157
Test
Data Structure and Algorithm
String
Multiple-choice
Reasoning
English
The nextval array for the string 'ababaaababaa' is ().
0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 0, 2
0, 1, 0, 1, 1, 4, 1, 1, 0, 1, 0, 2
0, 1, 0, 1, 0, 4, 2, 1, 0, 1, 0, 4
0, 1, 1, 1, 0, 2, 1, 1, 0, 1, 0, 4
C
The calculation process is as follows| index | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |------|----|----|----|----|----|----|----|----|----|----|----|----| | S | a | b | a | b | a | a | a | b |a |b | a | a | | next | 0 | 1 | 1 | 2 | 3 | 4 | 2 | 2 | 3 | 4 | 5 | 6 | | nextval | 0 | 1 | 0 | 1 | 0 | 4 | 2 | 1 | 0 | 1 | 0 | 4 |
158
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is a tree?
A recursive data structure with a hierarchical structure.
A finite set of n nodes, which is an empty tree when n=0.
A linear structure
Composed of parent nodes and child nodes, can form a closed loop.
A
null
159
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
How are the depth and height of a node defined?
Depth is the path length from the root to a node, while height is the longest path length from a node to a leaf.
Depth is the length of the path from a leaf to the root, while height is the length of the longest path from the root to a node.
All nodes have the same depth and height.
Depth and height cannot be determined.
A
null
160
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the direction of paths in a tree?
From top to bottom, from parent to child.
From bottom to top, from child to parent.
Bidirectional walking is possible between parents and children.
Children of the same parents share a path.
A
null
161
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
How many nodes at most can there be in the i-th level of a tree with degree m?
m to the power of i
pow(m, i)
pow(m, i-1)
m to the power of (i-1)
C
null
162
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
How many nodes can a m-ary tree of height h have at most?
pow(m, h) - 1
pow(m, h) - 1 / (m - 1)
(pow(m, h) - 1) / (m - 1)
h to the power of m
A
null
163
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
How is the path length of a tree defined?
The sum of the path lengths from the root to each node.
The sum of the lengths of all paths from leaf nodes to the root of the tree.
The total sum of path lengths between all nodes
The length of the longest path in a tree
A
null
164
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the definition of a binary tree?
Ordered tree, which can be empty.
A tree where each node has at most two children.
Unordered tree, cannot be empty.
A tree where each node has at most one child.
A
null
165
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What are the characteristics of nodes with degree 1 in a complete binary tree?
There is only one child and it is a left child
There may be multiple and on the right child.
There is only one child and it is a right child
It is impossible to have a node of degree 1.
A
null
166
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the height of a complete binary tree with n nodes?
log(n)
log(n + 1) or logn + 1
n
n+1
B
null
167
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the relationship between the number of leaf nodes and the number of nodes with degree 2 in a non-empty binary tree?
The number of leaf nodes is equal to the number of nodes with degree 2 plus 1.
The number of leaf nodes is equal to the number of nodes with degree 2.
The number of leaf nodes is less than the number of nodes with degree 2.
The number of leaf nodes is more than the number of nodes with degree 2 plus 1.
A
null
168
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the essence of threading a binary tree?
During the traversal process, change the null pointer to point to the predecessor or successor as a thread.
Replace all null pointers with newly added leaf nodes.
Create a complete binary tree
Randomly Linked Tree with Null Pointers
A
null
169
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
How to convert a general tree into a binary tree?
Draw a line between sibling nodes, maintaining the connection to the first child, and then rotate clockwise by 45°.
Decompose each node of the tree into multiple binary tree nodes.
Replace each node in the tree with the root node of a binary tree.
Delete all non-leaf nodes
A
null
170
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
How are null pointers handled during the threading process of a binary tree?
Replace with pointers to adjacent nodes.
Delete all null pointers
Replace with a new leaf node
Remain unchanged
A
null
171
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What are the characteristics of the insert operation in a binary sort tree?
If the key to be inserted already exists, do not insert.
Always create a new tree.
Insert the same keyword repeatedly
Replace existing identical keywords
A
null
172
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
How to construct a binary search tree?
Starting from an empty tree, insert the given keys one by one.
Create a tree with only a root node.
Create a complete binary tree.
Create a balanced binary tree.
A
null
173
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
How is the insertion operation performed in a binary search tree?
If the tree is empty, create a new node; otherwise, recursively insert into the left or right subtree.
Always inserted as the root node.
Be sure not to insert as a leaf node
Random node insertion
A
null
174
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the process of recursive search in a binary search tree?
Continuously compare keys along the tree, moving left or right until the key is found or a leaf node is reached.
Nodes in a Randomized Search Tree
Compare only the root nodes of the trees.
Compare all nodes until the key is found.
A
null
175
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the method for deleting a node with only one subtree in a binary search tree?
Replace the node with its subtree.
Delete the entire subtree
Preserve the node but delete its subtree.
Replace the node with the leaf of its subtree.
A
null
176
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the weighted path length of a node?
The path length from the root to the node
The product of the path length from the root to any node and the weight value on that node.
The weight of the node
The sum of the weights of all nodes
B
null
177
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the method for handling the deletion of leaf nodes in a binary search tree?
Directly delete the leaf node
Replace the leaf node with its left child.
Replace the leaf node with its right child.
Keep the leaf node as an empty node.
A
null
178
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What is the correct method to delete a node in a binary search tree?
If it is a leaf node, delete it directly. If there is only one child, let the subtree replace it. If there are two children, find the first in-order successor in the right child to fill in.
Always delete leaf nodes.
Randomly delete a node
Replace the node to be deleted with its right child.
A
null
179
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
How is the weighted path length of a tree defined?
Sum of weighted path lengths of all leaf nodes in a tree
The sum of the weighted path lengths of all nodes in a tree.
Weighted Path Length of the Root Node of a Tree
The depth of the tree multiplied by the sum of the weights of all leaf nodes.
A
null
180
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
What does the efficiency of searching in a binary search tree depend on?
The size of a tree
Depth of a tree
Tree width
Number of nodes in a tree
B
null
181
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
Trees are best suited for representing ().
Ordered
Disordered
Elements have multiple connections between them.
Elements have a hierarchical relationship among them.
D
null
182
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
The path length of a tree is the sum of the path lengths from the root to each node ( ).
Sum
Minimum Value
Maximum Value
mean
A
null
183
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
A binary tree with 10 leaf nodes has () nodes with degree 2.
8
9
10
11
B
null
184
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
The height h of a binary tree with 1025 nodes is ().
11
10
11 ~ 1025
10 ~ 1024
C
null
185
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
The purpose of introducing a threaded binary tree is to ().
Accelerate the speed of finding the predecessor or successor of a node.
To facilitate insertion and deletion in a binary tree
In order to easily find the parents
Ensure the traversal result of the binary tree is unique.
A
null
186
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
Threaded binary tree is a kind of () structure.
Logic
Logic and Storage
Physics
linear
C
null
187
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
When using a binary linked list to store a forest, the right pointer of the root node is ( ).
Point to the leftmost sibling
Point to the rightmost sibling
Must be empty
Not necessarily empty
D
null
188
Test
Data Structure and Algorithm
Tree
Multiple-choice
Knowledge
English
The structure of a Union-Find is a kind of ().
Binary tree stored in a binary linked list
Tree stored in parent representation
Sequential storage of binary tree
Child representation stored tree
B
null
189
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
For a tree with n nodes and a degree of 4, ().
The height of the tree is at most n-3.
The height of the tree is at most n-4.
The ith layer has at most 4(i-1) nodes.
There are exactly 4 nodes on at least one level.
A
To maximize the height of a tree with n nodes and a degree of 4, the number of nodes at each level should be minimized. Except for the last level, each level has 1 node, resulting in a final tree height of n-3. A degree of 4 for a tree only indicates that there is a node that has exactly (and at most) 4 child nodes, so option D is incorrect.
190
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
A tree of degree 4 and height h, ().
At least h+3 nodes
There are at most 4h-1 nodes.
At most 4h nodes
At least h+4 nodes
A
To minimize the total number of nodes in a tree with degree 4 and height h, the following two conditions must be met: ① There must be at least one node with 4 branches. ② The number of nodes at each level should be as few as possible.
191
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
The correct statement among the following is ().
In a complete binary tree, the left sibling of the parent of any leaf node (if it exists) is definitely not a leaf node.
For any binary tree, the number of leaf nodes is one less than the number of nodes with degree 2, that is, n_0 = n_2 - 1.
A complete binary tree is not suitable for sequential storage structure; only a full binary tree is suitable for sequential storage structure.
In a binary tree where nodes are numbered in level order as a complete binary tree, the number of the left child of the i-th node is 2i.
A
In a complete binary tree, the children of the left sibling of a leaf node's parent are definitely ahead of it (and must exist), so the parent's left sibling (if it exists) is definitely not a leaf node, A is correct. n_0 should be equal to n_2+1, B is incorrect. Both complete binary trees and full binary trees can use sequential storage structures, C is incorrect. The left child of the first node does not necessarily exist, D is incorrect. The general formula in option B applies to all binary trees, and we should be able to immediately think of using the special value substitution method to verify it, such as drawing a sketch of a full binary tree with only 3 nodes to check if it meets the condition.
192
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Let a binary tree with height h only have nodes of degree 0 and degree 2, then the minimum number of nodes contained in such a binary tree is ().
h
2h-1
2h+1
h+1
B
Except for the root node layer, which has only one node, all other h-1 layers have two nodes each, resulting in a total number of nodes = 2(h-1) + 1 = 2h - 1.
193
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Given a binary tree with only nodes of degree 0 and 2, and the number of nodes is 15, the maximum depth of the binary tree is ().
4
5
8
9
C
The first layer has one node, and each of the remaining h-1 layers has two nodes, with a total number of nodes = 1+2(h-1)=15, h=8.
194
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
If a binary tree has 126 nodes, the maximum number of nodes on the 7th level (with the root node at level 1) is ().
32
64
63
There is no seventh layer.
C
To maximize the number of nodes on the 7th level of a binary tree, considering only trees with a height of 7 levels, a full binary tree with 7 levels has 127 nodes. Since 126 is only one less than 127, the reduction can only occur on the 7th level. Therefore, the 7th level can have at most 2^6-1=63 nodes.
195
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
In a complete binary tree, where the root is numbered 1, we can determine whether the nodes with indices P and q are on the same level by ().
[log2p] = [log2q]
log2(p) = log2(q)
[log2p] + 1 = [log2q]
[log2p] + 1 = [log2q] + 1
A
Given the properties of a complete binary tree, the level of a node with index i (i≥1) is [log2i]+1. If two nodes are on the same level, then [log2p]+1=[log2q]+1 must hold true.
196
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Assuming a ternary tree has 50 nodes, its minimum height is ().
3
4
5
6
C
The problem is to find the minimum value of h such that 50 ≤ (3^h - 1)/2, which means h ≥ log3 101, and thus h = [log3 101] = 5.
197
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
For a full binary tree with n nodes and m leaf nodes, the height is h, then ().
n = h + m
n + m = 2h
m = h^-1
n = 2^h - 1
D
For a full binary tree with a height of h, n=2^0+2^1+...+2^(h-1)=2^h-1, m=2^(h-1), therefore, choose D.
198
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Among the following statements about binary tree traversal, the correct one is ().
If a node is the last node in the inorder traversal sequence of a subtree in a binary tree, then it must be the last node in the preorder traversal sequence of that subtree.
If a node is the last node in the preorder traversal sequence of a subtree in a binary tree, then it must be the last node in the inorder traversal sequence of that subtree.
If a leaf node is the last node in the inorder traversal sequence of a subtree in a binary tree, then it must be the last node in the preorder traversal sequence of that subtree.
If a leaf node is the last node in the preorder traversal sequence of a subtree in a binary tree, then it must be the last node in the inorder traversal sequence of that subtree.
C
The last node visited in the inorder traversal of a binary tree is definitely the node reached by following the right child pointer chain from the root, denoted by p. If node p is not a leaf node (its left subtree is not empty), then the last node visited in the preorder traversal is in its left subtree, A and B are incorrect: If node P is a leaf node, then the last node visited in both preorder and inorder traversals is itself, C is correct. If the last node p visited in the inorder traversal is not a leaf node and it has a left child q, where node q is a leaf node, then node q is the last node visited in the preorder traversal, but not the last in the inorder traversal, D is incorrect.
199
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
In any binary tree, if node a has a left child b and a right child c, then in the node's preorder, inorder, and postorder sequences, ().
Node b must be ahead of node a.
Node a must precede node c.
Node b must be ahead of node C.
Node a must be ahead of node b.
C
In these three traversal methods, regardless of which traversal method is used, the left subtree is always traversed before the right subtree, so node b is definitely visited before node c.
200
Test
Data Structure and Algorithm
Tree
Multiple-choice
Reasoning
English
Let n, m be two nodes on a binary tree. The condition for n to come before m in a post-order traversal is ().
n is to the right of m
n is an ancestor of m
n is to the left of m
n is a descendant of m.
D
The order of post-order traversal is LRN. If n is in the left subtree of N, and m is in the right subtree of N, then n is visited before m during the post-order traversal process: if n is a descendant of m, and m is at the position of N, then whether n is in the left or right subtree of m, n is visited before m during the post-order traversal. No other conditions apply. For C to hold true, an additional condition must be added that the two nodes are on the same level.