判断题 总分: 35 / 35
1-1 答案正确 得分: 4 / 4
When measuring the relevancy of the answer set, if the precision is low but the recall is high, it means that most of the relevant documents are missing, but most of the retrieved documents are relevant. (4 分)
T F 1-2 答案正确 得分: 3 / 3
In amortized analysis, a good potential function should always assume its minimum at the start of the sequence. (3 分)
T F 1-3 答案正确 得分: 3 / 3
In a red-black tree, the number of rotations in the DELETE operation is O(1).
(3 分)
T F 1-4 答案正确 得分: 4 / 4
Finding the maximum key from a splay tree will result in a tree with its root having no left subtree. (4 分)
T F 1-5 答案正确 得分: 4 / 4
In an AVL tree, it is possible to have this situation that the balance factors of a node and both of its children are all +1. (4 分)
T F 1-6 答案正确 得分: 3 / 3
Making
N
insertions into an initally empty binomial queue takesΘ(NlogN)
time in the worst case. (3 分) T F
1-7 答案正确 得分: 3 / 3
The time bound of the FIND operation in a B+ tree containing
N
numbers isO(lonN)
, no matter what the degree of the tree is. (3 分) T F1-8 答案正确 得分: 3 / 3
In backtracking, if different solution spaces have different sizes, start testing from the partial solution with the largest space size would have a better chance to reduce the time cost. (3 分)
T F 1-9 答案正确 得分: 4 / 4
A perfectly balanced tree forms if keys 1 to
2k−1
are inserted in order into an initally empty skew heap. (4 分)T F 1-10 答案正确 得分: 4 / 4
For the recurrence equation
T(N)=aT(N/b)+f(N)
, ifaf(N/b)=f(N)
, thenT(N)=Θ(f(N)logbN)
. (4 分)T F
选择题 总分: 35 / 40
2-1 答案正确 得分: 5 / 5
A queue can be implemented by using two stacks
SA
andSB
as follows: To enqueue
x
, we pushx
ontoSA
. To dequeue from the queue, we pop and return the top item from
SB
.However, if
SB
is empty, we first fill it (and emptySA
) by popping the top item fromSA
, pushing this item ontoSB
, and repeat untilSA
is empty.
Assuming that push and pop operations take
O(1)
worst-case time, please select a potential functionϕ
which can help us prove that enqueue and dequeueoperations take
O(1)
amortized time (when starting from an empty queue). (5 分)1.
ϕ=2∣SA∣
2.
ϕ=∣SA∣
3.
ϕ=2∣SB∣
4.
ϕ=∣SB∣
2-2 答案正确 得分: 5 / 5
Given the following game tree, which node in the right subtree is the first node to be pruned with α-β pruning algorithm? (5 分)
1. d 2. a 3. c 4. b
2-3 答案正确 得分: 5 / 5
3-way-mergesort : Suppose instead of dividing in two halves at each step of the mergesort, we divide into three one thirds, sort each part, and finally combine all of them using a three-way-merge. What is the overall time complexity of this algorithm ? (5 分)
1.
O(n)
2.
O(n(log2n))
3.
O(n2logn)
4.
O(nlogn)
2-4 答案正确 得分: 5 / 5
For the result of accessing 9 in the splay tree in the following figure, besides saying that 9 must be the root, which one of the following statements is also TRUE? (5 分)
1. 12 and 21 are siblings 2. 4 and 21 are siblings 3. 12 is a leaf node 4. 8 and 21 are siblings
2-5 答案错误 得分: 0 / 5
Delete a node
v
from an AVL treeT1
, we can obtain another AVL treeT2
. Theninsert
v
intoT2
, we can obtain another AVL treeT3
. Which one(s) of the following statements aboutT1
andT3
is(are) true? (5 分) I、If
v
is a leaf node inT1
, thenT1
andT3
might be different. II、If
v
is not a leaf node inT1
, thenT1
andT3
must be different. III、If
v
is not a leaf node inT1
, thenT1
andT3
must be the same.1. I and II only 2. I and III only 3. I only
4. II only
2-6 答案正确 得分: 5 / 5
Insert { 3, 1, 4, 5, 0, 9, 2, 6, 8, 7 } into an initially empty 2-3 tree (with splitting). Which one of the following statements is FALSE? (5 分)
1. 6 and 7 are in the same node 2. there are 5 leaf nodes
3. the first key stored in the root is 6
4. the parent of the node containing 5 has 3 children
2-7 答案正确 得分: 5 / 5
There are 28000 documents in the database. The statistic data for one query are shown in the following table. The recall is: __ (5 分)
Relevant Irrelevant
Retrieved 4000 12000
Not Retrieved 8000 4000
1. 25%
2. 14%
3. 33%
4. 50%
2-8 答案正确 得分: 5 / 5
Merge the two skew heaps in the following figure. Which one of the following statements is FALSE? (5 分)
1. the null path length of 6 is the same as that of 2 2. 1 is the root with 3 being its right child
3. 5 is the right child of 4
4. Along the left most path from top down, we have 1, 2, 6, and 8
程序填空题 总分: 25 / 25
5-1 答案正确 得分: 10 / 10
The functions BinQueue_Find and Recur_Find are to find X in a binomial queue H. Return the node pointer if found, otherwise return NULL.
BinTree BinQueue_Find( BinQueue H, ElementType X ) {
BinTree T, result = NULL;
int i, j;
for( i=0, j=1; j<=H->CurrentSize; i++, j*=2) { /* for each tree in H */
T= H->TheTrees[i];
if ( X >=T->Elem ent
(10 分) ){ /* if need to search inside this tree */
result = Recur_Find(T, X);
if ( result != NULL ) return result;
} }
return result;
}
BinTree Recur_Find( BinTree T, ElementType X ) {
BinTree result = NULL;
if ( X==T->Element ) return T;
if ( T->LeftChild!=N U ){
result = Recur_Find(T->LeftChild, X);
if ( result!=NULL ) return result;
}
if ( T->NextSibling!=NULL )
result = Recur_Find(T->NextSibling, X);
return result;
}
分数组成 结果 得分
1 答案正确 5
2 答案正确 5
5-2 答案正确 得分: 15 / 15 IsRBTree (3)
The functions IsRBTree is to check if a given binary search tree T is a red- black tree. Return true if T is, or false if not.
The red-black tree structure is defined as the following:
typedef enum { red, black } colors;
typedef struct RBNode *PtrToRBNode;
struct RBNode{
int Data;
PtrToRBNode Left, Right, Parent;
int BH; /* black height */
colors Color;
};
typedef PtrToRBNode RBTree;
Please fill in the blanks.
bool IsRBTree( RBTree T )
{
int LeftBH, RightBH;
if ( !T ) return true;
if ( T->Color == black ) T->BH = 1;
else {
if ( T->Left && (T->Left->Color == red)) return false;
if ( T->Right && T->R ight->Color
(15 分) ) return false;
}
if ( !T->Left && !T->Right ) return true;
if ( IsR B Tree(T->R ig ) {
if ( T->Left ) LeftBH = T->Left->BH;
else LeftBH = 0;
if ( T->Right ) RightBH = T->Right->BH;
else RightBH = 0;
if ( LeftBH == RightBH ) { T->B H =LeftB H +T
; return true;
}
else return false;
}
else return false;
}
分数组成 结果 得分
1 答案正确 5
2 答案正确 5
3 答案正确 5