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.
A perfectly balanced tree forms if keys 1 to are inserted in order into an initally empty leftist heap.
In a red-black tree, the number of rotations in the DELETE operation is O(1).
For the recurrence equation , if , then .
Making insertions into an initally empty binomial queue takes time in the worst case.
In amortized analysis, a good potential function should always assume its maximum at the start of the sequence.
Finding the minimum key from a splay tree will result in a tree with its root having no left subtree.
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.
In backtracking, if different solution spaces have different sizes, start testing from the partial solution with the smallest space size would have a better chance to reduce the time cost.
The time bound of the FIND operation in a B+ tree containing numbers is , no matter what the degree of the tree is.
Given the following game tree, which node in the right subtree is the first node to be pruned with α-β pruning algorithm?
Insert { 5, 1, 7, 8, 21, 2, 12, 19, 13, 0 } into an initially empty 2-3 tree (with splitting). Which one of the following statements is FALSE?
There are 8000 documents in the database. The statistic data for one query are shown in the following table. The precision is: __
Relevant | Irrelevant | |
---|---|---|
Retrieved | 1000 | 1000 |
Not Retrieved | 2000 | 4000 |
For the result of accessing 11 in the splay tree in the following figure, besides saying that 11 must be the root, which one of the following statements is also TRUE?
A queue can be implemented by using two stacks and as follows:
Assuming that push and pop operations take worst-case time, please select a potential function which can help us prove that enqueue and dequeue operations take amortized time (when starting from an empty queue).
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 ?
Delete a node from an AVL tree , we can obtain another AVL tree . Then insert into , we can obtain another AVL tree . Which one(s) of the following statements about and is(are) true?
Merge the two leftist heaps in the following figure. Which one of the following statements is FALSE?
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 (5分) ){ /* 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 ( (5分) ){
result = Recur_Find(T->LeftChild, X);
if ( result!=NULL ) return result;
}
if ( T->NextSibling!=NULL )
result = Recur_Find(T->NextSibling, X);
return result;
}
The functions IsRBT
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 BlackHeight;
colors Color;
};
typedef PtrToRBNode RBTree;
Please fill in the blanks.
bool IsRBT( RBTree T )
{
int LeftBH, RightBH;
if ( !T ) return true;
if ( T->Color == black ) T->BlackHeight = 1;
else {
if ( T->Left && (5分)) return false;
if ( T->Right && (T->Right->Color == red) ) return false;
}
if ( !T->Left && !T->Right ) return true;
if ( (5分)) {
if ( T->Left ) LeftBH = T->Left->BlackHeight;
else LeftBH = 0;
if ( T->Right ) RightBH = T->Right->BlackHeight;
else RightBH = 0;
if ( LeftBH == RightBH ) {
(5分);
return true;
}
else return false;
}
else return false;
}