Deck 9: Trees

Full screen (f)
exit full mode
Question
The predecessor of a node is called its __________.

A) sibling
B) parent
C) child
D) descendant
Use Space or
up arrow
down arrow
to flip the card.
Question
A(n) __________ of a node is a tree whose root is a child of that node.
Question
The height of a tree is the same as the height of its root node.
Question
A set of nodes T is a binary tree if either of the following is true:
• __________
• If T is not empty, it has a root node r with 0, 1, or 2 binary subtrees whose roots are connected to r by a branch.

A) T is complete
B) T is balanced
C) T is full
D) T is empty
Question
In an expression tree, operands are stored in the __________ node(s).

A) internal
B) leaf
C) root
D) ancestor
Question
To decode a file of letters and spaces, you walk down the Huffman tree, starting at the root, until you reach a(n) __________.
Question
Searching a binary search tree is an O(__________) process.

A) 1
B) log n
C) n
D) n log n
Question
A(n) complete binary tree of height h is filled up to depth __________ and, at depth h, any unfilled nodes are on the right.
Question
The process of walking through a tree in a prescribed order and visiting the nodes as they are encountered in known as tree __________.
Question
You may not define member functions in a C++ struct type.
Question
Complete the definition of Binary_Tree member function is_null.
template<typename Item_Type>
bool Binary_Tree<Item_Type>::is_null() const
{
/**missing code goes here*/
__________
}
Question
Which of the following lines completes the definition of is_leaf?
<strong>Which of the following lines completes the definition of is_leaf?  </strong> A) return root->left == NULL; B) return root->right == NULL; C) return root->left == NULL || root->right == NULL; D) return root->left == NULL && root->right == NULL; <div style=padding-top: 35px>

A) return root->left == NULL;
B) return root->right == NULL;
C) return root->left == NULL || root->right == NULL;
D) return root->left == NULL && root->right == NULL;
Question
A(n) __________ pointer is a class that acts like a pointer, but automatically deletes the object pointed to when the pointed-to object has no owners.
Question
In the worst case scenario, a search against an unbalanced binary search has a performance cost of O(__________).

A) 1
B) log n
C) n
D) n log n
Question
Which of the following lines completes the insert starter function?
<strong>Which of the following lines completes the insert starter function?  </strong> A) return insert(root, item); B) return insert(this->root, item); C) return insert(item); D) return insert(this, item); <div style=padding-top: 35px>

A) return insert(root, item);
B) return insert(this->root, item);
C) return insert(item);
D) return insert(this, item);
Question
In a binary search tree, the parent must be smaller than all of the data fields in the left subtree and larger than all of the data fields in the right subtree.
Question
Enable the replace_parent function to maintain a connection to the subtree originally pointed to by local_root, by using the line __________.
Enable the replace_parent function to maintain a connection to the subtree originally pointed to by local_root, by using the line __________.  <div style=padding-top: 35px>
Question
A(n) __________ is a substring that is delimited by a pair of delimiter characters (examples of delimiter characters are spaces and punctuation symbols).
Question
A heap is a complete binary tree with the following properties:
• The value in the root is greater than or equal to all items in the tree.
• __________
Question
Removal from a heap is always from the top.
Question
For a node at position p in a vector representing a heap, the left child is at __________.

A) 2p
B) 2p + 1
C) 2p + 2
D) 2p - 1
Question
Both heap insert and remove are O(__________), where n is the number of items in the heap.

A) log n
B) n
C) n2
D) n3
Question
Priority queues violate the FIFO property of an ordinary queue.
Question
To remove an item from the priority queue, we take the __________ item from the underlying vector container; this is the largest item.
Question
When using the ASCII code to make messages, the length of a message would be __________ where n is the total number of characters.

A) 8 * log n
B) 8 * n
C) 8 * n log n
D) 8 * n2
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 9: Trees
1
The predecessor of a node is called its __________.

A) sibling
B) parent
C) child
D) descendant
parent
2
A(n) __________ of a node is a tree whose root is a child of that node.
subtree
3
The height of a tree is the same as the height of its root node.
True
4
A set of nodes T is a binary tree if either of the following is true:
• __________
• If T is not empty, it has a root node r with 0, 1, or 2 binary subtrees whose roots are connected to r by a branch.

A) T is complete
B) T is balanced
C) T is full
D) T is empty
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
5
In an expression tree, operands are stored in the __________ node(s).

A) internal
B) leaf
C) root
D) ancestor
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
6
To decode a file of letters and spaces, you walk down the Huffman tree, starting at the root, until you reach a(n) __________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
7
Searching a binary search tree is an O(__________) process.

A) 1
B) log n
C) n
D) n log n
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
8
A(n) complete binary tree of height h is filled up to depth __________ and, at depth h, any unfilled nodes are on the right.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
9
The process of walking through a tree in a prescribed order and visiting the nodes as they are encountered in known as tree __________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
10
You may not define member functions in a C++ struct type.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
11
Complete the definition of Binary_Tree member function is_null.
template<typename Item_Type>
bool Binary_Tree<Item_Type>::is_null() const
{
/**missing code goes here*/
__________
}
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following lines completes the definition of is_leaf?
<strong>Which of the following lines completes the definition of is_leaf?  </strong> A) return root->left == NULL; B) return root->right == NULL; C) return root->left == NULL || root->right == NULL; D) return root->left == NULL && root->right == NULL;

A) return root->left == NULL;
B) return root->right == NULL;
C) return root->left == NULL || root->right == NULL;
D) return root->left == NULL && root->right == NULL;
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
13
A(n) __________ pointer is a class that acts like a pointer, but automatically deletes the object pointed to when the pointed-to object has no owners.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
14
In the worst case scenario, a search against an unbalanced binary search has a performance cost of O(__________).

A) 1
B) log n
C) n
D) n log n
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following lines completes the insert starter function?
<strong>Which of the following lines completes the insert starter function?  </strong> A) return insert(root, item); B) return insert(this->root, item); C) return insert(item); D) return insert(this, item);

A) return insert(root, item);
B) return insert(this->root, item);
C) return insert(item);
D) return insert(this, item);
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
16
In a binary search tree, the parent must be smaller than all of the data fields in the left subtree and larger than all of the data fields in the right subtree.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
17
Enable the replace_parent function to maintain a connection to the subtree originally pointed to by local_root, by using the line __________.
Enable the replace_parent function to maintain a connection to the subtree originally pointed to by local_root, by using the line __________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
18
A(n) __________ is a substring that is delimited by a pair of delimiter characters (examples of delimiter characters are spaces and punctuation symbols).
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
19
A heap is a complete binary tree with the following properties:
• The value in the root is greater than or equal to all items in the tree.
• __________
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
20
Removal from a heap is always from the top.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
21
For a node at position p in a vector representing a heap, the left child is at __________.

A) 2p
B) 2p + 1
C) 2p + 2
D) 2p - 1
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
22
Both heap insert and remove are O(__________), where n is the number of items in the heap.

A) log n
B) n
C) n2
D) n3
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
23
Priority queues violate the FIFO property of an ordinary queue.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
24
To remove an item from the priority queue, we take the __________ item from the underlying vector container; this is the largest item.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
25
When using the ASCII code to make messages, the length of a message would be __________ where n is the total number of characters.

A) 8 * log n
B) 8 * n
C) 8 * n log n
D) 8 * n2
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 25 flashcards in this deck.