Deck 11: Binary Trees and B-Trees
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/47
Play
Full screen (f)
Deck 11: Binary Trees and B-Trees
1
When data is being organized, a programmer's highest priority is to organize it in such a way that item insertion, deletion, and lookups (searches) are fast.
True
2
Because an array is not a random access data structure, we cannot use a binary search to effectively find and retrieve an item from an array list.
False
3
In an array, item insertion (especially if the array is sorted) and item deletion can be very time consuming, especially if the list size is very large.
True
4
Item insertion and deletion in a linked list requires significant data movement.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
5
A sequential search is good only for very small lists because the average search length of a sequential search is half the size of the list.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
6
Every node in a binary tree has at most three children.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
7
A binary tree is a dynamic data structure.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
8
After inserting an item in a binary search tree, the resulting binary tree must also be a binary search tree.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
9
In a preorder traversal of a binary tree, for each node, first the node is visited, then the right subtree is visited, and then the left subtree is visited.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
10
In a preorder traversal of a binary tree, after visiting a node and before moving to the right subtree, we must save a pointer to the node so that after visiting the right subtree, we can visit the left subtree.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
11
As in the case of an inorder traversal, in a postorder traversal, the first node visited is the rightmost node of the binary tree.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
12
To specify a function as a formal parameter to another function, we specify the function type, followed by the function name as a pointer, followed by the parameter types of the function.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
13
The performance of the search algorithm on a binary search tree depends on how large the binary tree is.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
14
Because an AVL tree is a binary search tree, the search algorithm for an AVL tree is the same as the search algorithm for a binary search tree.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
15
Operations, such as finding the height, determining the number of nodes, checking whether the tree is empty, tree traversal, and so on, on AVL trees cannot be implemented the same way they are implemented on binary trees.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
16
After inserting (or deleting) a node from an AVL tree, the resulting binary tree does not have to be an AVL tree.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
17
To insert an item in an AVL tree, first we search the tree and find the place where the new item is to be inserted.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
18
After inserting the node, the reconstruction can occur at any node on the path back to the root node.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
19
The performance of a binary search tree depends on the width of the tree.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
20
Each node should store the number of keys in the node, the records, and the pointer to subtrees.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
21
The class implementing the properties of a B-tree must, among others, implement the search, traversal, insertion, and deletion algorithms.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
22
A search in a B-tree must start at the bottom node.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
23
When inserting into a B-tree, if the key is already in the tree, you should output an error message.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
24
To implement the insertion algorithm in a B-tree, we only need algorithms to split a node and insert an item into a node.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
25
When deleting from a B-tree, if the leaf contains only the minimum number of keys, look at the sibling nodes that are adjacent to the leaf.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
26
To speed up item insertion and deletion in a data set, use ____.
A) arrays
B) linked lists
C) classes
D) ADTs
A) arrays
B) linked lists
C) classes
D) ADTs
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
27
One of the drawbacks of linked lists is that they must be processed ____.
A) recursively
B) in order
C) out of order
D) sequentially
A) recursively
B) in order
C) out of order
D) sequentially
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
28
The item insertion, deletion, and lookup operations require that the binary tree be ____.
A) duplicated
B) traversed
C) inverted
D) converted
A) duplicated
B) traversed
C) inverted
D) converted
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
29
In a ____ traversal of a binary tree, for each node, first the left subtree is visited, then the right subtree is visited, and then the node is visited.
A) preorder
B) inorder
C) postorder
D) recursive
A) preorder
B) inorder
C) postorder
D) recursive
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
30
In C++, a function name without any parentheses is considered a ____.
A) reference to the function
B) address of the function
C) pointer to an entry point
D) pointer to the function
A) reference to the function
B) address of the function
C) pointer to an entry point
D) pointer to the function
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
31
The ____ is one in which the resulting binary search is nearly balanced.
A) ABL tree
B) AVL tree
C) BVL tree
D) BDL tree
A) ABL tree
B) AVL tree
C) BVL tree
D) BDL tree
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
32
The balance factor of x, written bf(x), is defined by ____.
A) bf(x)= xl - x1
B) bf(x)= x1 - xh
C) bf(x)= xh - x1
D) bf(x)= l(xh) - l(x1)
A) bf(x)= xl - x1
B) bf(x)= x1 - xh
C) bf(x)= xh - x1
D) bf(x)= l(xh) - l(x1)
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
33
Let x be a node in a binary tree, then we say that the node x violates the ____ if |xh - x1| > 1, that is, the heights of the left and right subtrees of x differ by more than 1.
A) balance criteria
B) balance factor
C) rebalance criteria
D) rebalance factor
A) balance criteria
B) balance factor
C) rebalance criteria
D) rebalance factor
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
34
If the item to be inserted in an AVL tree is already in the tree, the search ends at a ____.
A) leaf node
B) linear subtree
C) linked subtree
D) nonempty subtree
A) leaf node
B) linear subtree
C) linked subtree
D) nonempty subtree
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
35
There are two types of AVL tree rotations: ____.
A) left rotation and right rotation
B) inner rotation and outer rotation
C) inner rotation and left rotation
D) right rotation and left inversion
A) left rotation and right rotation
B) inner rotation and outer rotation
C) inner rotation and left rotation
D) right rotation and left inversion
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
36
The reconstruction procedure for an AVL tree is called ____.
A) reverting the tree
B) balancing the tree
C) rotating the tree
D) inverting the tree
A) reverting the tree
B) balancing the tree
C) rotating the tree
D) inverting the tree
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
37
To delete a node, we adjust one of the pointers of the ____.
A) leaf node
B) parent node
C) branch node
D) child node
A) leaf node
B) parent node
C) branch node
D) child node
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
38
In the worst case, the height of an AVL tree with n nodes is approximately ____.
A) (1.44)logn
B) (1.44)nlogn
C) (1.44)log2n
D) (1.44)logn2
A) (1.44)logn
B) (1.44)nlogn
C) (1.44)log2n
D) (1.44)logn2
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
39
The height of a perfectly balanced binary tree with n nodes is ____.
A) logn
B) n2
C) nlogn
D) log2n
A) logn
B) n2
C) nlogn
D) log2n
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
40
An ____ is a tree in which each node has at most m children.
A) m-way search tree
B) m-level search tree
C) m-node search tree
D) m-height search tree
A) m-way search tree
B) m-level search tree
C) m-node search tree
D) m-height search tree
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
41
In a ____ the root has at least 2 children if it is not a leaf, and at most m children.
A) B-tree of height m
B) B-tree of level m
C) B-tree of size m
D) B-tree of order m
A) B-tree of height m
B) B-tree of level m
C) B-tree of size m
D) B-tree of order m
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
42
The basic operations performed on a B-tree are search the tree, insert an item in the tree, delete an item from the tree, and ____.
A) rotate the tree
B) balance the tree
C) traverse the tree
D) copy the tree
A) rotate the tree
B) balance the tree
C) traverse the tree
D) copy the tree
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
43
The function ____ searches the binary search tree for a given item.
A) insert
B) search
C) replace
D) traverse
A) insert
B) search
C) replace
D) traverse
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
44
A B-tree can be ____ in three ways: inorder, preorder, and postorder.
A) copied
B) reversed
C) traversed
D) inversed
A) copied
B) reversed
C) traversed
D) inversed
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
45
When inserting into a B-tree, if the key is not in the tree, the search terminates at a ____.
A) leaf
B) root
C) node
D) branch
A) leaf
B) root
C) node
D) branch
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
46
When inserting into a B-tree, if the leaf is full, split the node into two nodes and the median key is moved to the ____ node.
A) child
B) empty
C) adjacent
D) parent
A) child
B) empty
C) adjacent
D) parent
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
47
Because the insertion of an item might require the splitting of a node and moving the median key to the parent node, the simplest way to implement the insertion algorithm is to use ____.
A) recursion
B) iteration
C) inversion
D) sequential traversal
A) recursion
B) iteration
C) inversion
D) sequential traversal
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck