Deck 19: Binary Trees

Full screen (f)
exit full mode
Question
Every node in a binary tree has at most ____ children.

A) one
B) two
C) three
D) four
Use Space or
up arrow
down arrow
to flip the card.
Question
To delete an item from the binary search tree,you must do the following:
1.Find the node containing the item (if any)to be deleted.
2.Delete the node.
Question
A binary tree has a special node called the ____ node.

A) super
B) root
C) superparent
D) rootleaf
Question
A pointer to the root node of the binary tree is stored outside the binary tree in a pointer variable,usually called the ____.

A) node
B) parent
C) root
D) nodeType
Question
In a diagram of a binary tree,each node is represented as a(n)____.

A) line
B) triangle
C) circle
D) rectangle
Question
In C++,a function name without any parentheses is considered a pointer to the function.
Question
After deleting the desired item from a binary search tree,the resulting tree must be a binary search tree.
Question
In the diagram of a binary tree,an arrow is called a(n)____.

A) relation
B) path
C) directed line
D) directed branch
Question
The level of the root node of a binary tree is 1.
Question
Three lines at the end of an arrow in the diagram of a binary tree indicate that the subtree ____.

A) has three branches
B) has three children
C) is full
D) is empty
Question
All binary tree traversals start at the left-most child node.
Question
The operations to do inorder,preorder,and postorder traversals of a binary search tree are the same as those for a binary tree.
Question
A node in a binary tree is called a(n)____ if it has no left and right children.

A) edge
B) branch
C) leaf
D) path
Question
Duplicates are allowed in a binary search tree.
Question
For classes with pointer data members,you must explicitly overload the assignment operator and include the destructor.
Question
Consider that A is a binary tree,C and D are the subtrees of A.Which of the following statements is always true?

A) C and D are binary trees.
B) C and D are search binary trees.
C) C and D are empty trees.
D) A is empty.
Question
The item search,insertion,and deletion operations all require the binary tree to be traversed.
Question
Each link in a binary tree node points to a(n)____ of that node.

A) parent
B) child
C) value
D) sibling
Question
Every node in a binary tree has ____ pointers.

A) one
B) two
C) three
D) four
Question
In a binary tree,the branches go only from a child to a parent.
Question
When traversing a binary tree with the pointer current,the pointer current is initialized to ____.

A) NULL
B) llink
C) rlink
D) root
Question
The ____________________ of a path in a binary tree is the number of branches on that path.
Question
The sequence of operations in a postorder traversal is ____.

A) traverse left; traverse right
B) traverse left; traverse right; visit
C) visit; traverse left; traverse right
D) traverse left; visit; traverse right
Question
In copying a binary tree,if you use just the value of the pointer of the root node,you get a ____ copy of the data.

A) static
B) shallow
C) deep
D) local
Question
The listing of the nodes produced by the postorder traversal of a binary tree is called the ____.

A) postsequence
B) postorder sequence
C) postorder table
D) post-script
Question
The key of the right child below the root node of a search binary tree is 40.The value in the root node could be ____.

A) 30
B) 40
C) 50
D) 60
Question
In a binary search tree,the data in each node is ____ the data in the left child.

A) larger than
B) smaller than
C) equal to
D) larger or equal to
Question
A binary tree is empty if root is ____.

A) 0
B) 1
C) "zero"
D) NULL
Question
The three traversal algorithms discussed for binary trees are ____,____,and ____.

A) order, preorder, postorder
B) in, preorder, order
C) order, preorder, post
D) inorder, preorder, postorder
Question
A binary tree is also a(n)____.

A) stack
B) linked list
C) graph
D) array
Question
In a binary search tree,the data in each node is ____ the data in the right child.

A) equal to
B) smaller than
C) greater than
D) smaller or equal to
Question
The ____ of a node in a binary tree is the number of branches on the path from the root to the node.

A) height
B) level
C) width
D) size
Question
In a(n)____________________ traversal,the binary tree is traversed as follows:
1.Traverse the left subtree
2.Visit the node
3.Traverse the right subtree
Question
The listing of the nodes produced by the preorder traversal of a binary tree is called the ____________________.
Question
The most common operation performed on a binary tree is a(n)____.

A) insertion
B) deletion
C) search
D) traversal
Question
In a(n)____________________ traversal,the binary tree is traversed as follows:
1. Visit the node.
2.Traverse the left subtree.
3.Traverse the right subtree.
Question
In a binary tree,the level of the children of the root node is ____.

A) 0
B) 1
C) 2
D) 3
Question
The search function searches the binary search tree for a given item.If the item is found in the binary search tree,it returns ____.

A) true
B) false
C) a reference to the node where the item was found
D) 1
Question
The ____________________ of a binary tree is the number of nodes on the longest path from the root to a leaf.
Question
Assume the key of the left child below the root node of a binary search tree is 30.The value in the root node could be ____.

A) 0
B) 10
C) 30
D) 40
Question
When a class object is passed by value,the ____________________ constructor copies the value of the actual parameters into the formal parameters.
Question
Let T be a binary search tree with n nodes,in which n > 0.When T is linear,the search algorithm makes ____________________ key comparisons,in the unsuccessful case.
Question
The listing of the nodes produced by the inorder traversal of a binary tree is called the ____________________.
Question
Let T be a binary search tree with n nodes,in which n > 0.The average number of nodes visited in a search of T is approximately O(____________________).
Question
To destroy a binary tree,for each node,first we destroy its left subtree,then its right subtree,and then the node itself.We must then use the operator ____________________ to deallocate the memory occupied by the node.
Question
Let T be a binary search tree with n nodes,in which n > 0.The number of key comparisons is approximately O(____________________).
Question
After inserting an item in a binary search tree,the resulting binary tree must be a(n)____________________.
Question
In addition to the inorder,preorder,and postorder traversals,a binary tree can also be traversed level-by-level,which is also known as ____________________ traversal.
Question
1.current = root;
2.while (current is not NULL or stack is nonempty)
if (current is not NULL)
{
visit current node;
push current onto stack;
current = current->lLink;
}
else
{
current = stack.top();
pop stack;
current = current->rLink; //move to the right child
}
Question
The algorithm below describes the nonrecursive ____________________ traversal of a binary tree.
1.current = root;
2.while (current is not NULL or stack is nonempty)
if (current is not NULL)
{
push current onto stack;
current = current->lLink;
}
else
{
current = stack.top();
pop stack;
visit current; //visit the node
current = current->rLink;//move to right child
}
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 19: Binary Trees
1
Every node in a binary tree has at most ____ children.

A) one
B) two
C) three
D) four
B
2
To delete an item from the binary search tree,you must do the following:
1.Find the node containing the item (if any)to be deleted.
2.Delete the node.
True
3
A binary tree has a special node called the ____ node.

A) super
B) root
C) superparent
D) rootleaf
B
4
A pointer to the root node of the binary tree is stored outside the binary tree in a pointer variable,usually called the ____.

A) node
B) parent
C) root
D) nodeType
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
In a diagram of a binary tree,each node is represented as a(n)____.

A) line
B) triangle
C) circle
D) rectangle
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
In C++,a function name without any parentheses is considered a pointer to the function.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
After deleting the desired item from a binary search tree,the resulting tree must be a binary search tree.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
In the diagram of a binary tree,an arrow is called a(n)____.

A) relation
B) path
C) directed line
D) directed branch
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
The level of the root node of a binary tree is 1.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
Three lines at the end of an arrow in the diagram of a binary tree indicate that the subtree ____.

A) has three branches
B) has three children
C) is full
D) is empty
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
All binary tree traversals start at the left-most child node.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
The operations to do inorder,preorder,and postorder traversals of a binary search tree are the same as those for a binary tree.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
A node in a binary tree is called a(n)____ if it has no left and right children.

A) edge
B) branch
C) leaf
D) path
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
Duplicates are allowed in a binary search tree.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
For classes with pointer data members,you must explicitly overload the assignment operator and include the destructor.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
Consider that A is a binary tree,C and D are the subtrees of A.Which of the following statements is always true?

A) C and D are binary trees.
B) C and D are search binary trees.
C) C and D are empty trees.
D) A is empty.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
The item search,insertion,and deletion operations all require the binary tree to be traversed.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
Each link in a binary tree node points to a(n)____ of that node.

A) parent
B) child
C) value
D) sibling
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
Every node in a binary tree has ____ pointers.

A) one
B) two
C) three
D) four
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
In a binary tree,the branches go only from a child to a parent.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
When traversing a binary tree with the pointer current,the pointer current is initialized to ____.

A) NULL
B) llink
C) rlink
D) root
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
The ____________________ of a path in a binary tree is the number of branches on that path.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
The sequence of operations in a postorder traversal is ____.

A) traverse left; traverse right
B) traverse left; traverse right; visit
C) visit; traverse left; traverse right
D) traverse left; visit; traverse right
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
In copying a binary tree,if you use just the value of the pointer of the root node,you get a ____ copy of the data.

A) static
B) shallow
C) deep
D) local
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
The listing of the nodes produced by the postorder traversal of a binary tree is called the ____.

A) postsequence
B) postorder sequence
C) postorder table
D) post-script
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
The key of the right child below the root node of a search binary tree is 40.The value in the root node could be ____.

A) 30
B) 40
C) 50
D) 60
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
In a binary search tree,the data in each node is ____ the data in the left child.

A) larger than
B) smaller than
C) equal to
D) larger or equal to
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
A binary tree is empty if root is ____.

A) 0
B) 1
C) "zero"
D) NULL
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
The three traversal algorithms discussed for binary trees are ____,____,and ____.

A) order, preorder, postorder
B) in, preorder, order
C) order, preorder, post
D) inorder, preorder, postorder
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
A binary tree is also a(n)____.

A) stack
B) linked list
C) graph
D) array
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
In a binary search tree,the data in each node is ____ the data in the right child.

A) equal to
B) smaller than
C) greater than
D) smaller or equal to
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
The ____ of a node in a binary tree is the number of branches on the path from the root to the node.

A) height
B) level
C) width
D) size
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
In a(n)____________________ traversal,the binary tree is traversed as follows:
1.Traverse the left subtree
2.Visit the node
3.Traverse the right subtree
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
The listing of the nodes produced by the preorder traversal of a binary tree is called the ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
The most common operation performed on a binary tree is a(n)____.

A) insertion
B) deletion
C) search
D) traversal
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
In a(n)____________________ traversal,the binary tree is traversed as follows:
1. Visit the node.
2.Traverse the left subtree.
3.Traverse the right subtree.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
In a binary tree,the level of the children of the root node is ____.

A) 0
B) 1
C) 2
D) 3
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
The search function searches the binary search tree for a given item.If the item is found in the binary search tree,it returns ____.

A) true
B) false
C) a reference to the node where the item was found
D) 1
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
The ____________________ of a binary tree is the number of nodes on the longest path from the root to a leaf.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
Assume the key of the left child below the root node of a binary search tree is 30.The value in the root node could be ____.

A) 0
B) 10
C) 30
D) 40
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
When a class object is passed by value,the ____________________ constructor copies the value of the actual parameters into the formal parameters.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
Let T be a binary search tree with n nodes,in which n > 0.When T is linear,the search algorithm makes ____________________ key comparisons,in the unsuccessful case.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
The listing of the nodes produced by the inorder traversal of a binary tree is called the ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
Let T be a binary search tree with n nodes,in which n > 0.The average number of nodes visited in a search of T is approximately O(____________________).
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
To destroy a binary tree,for each node,first we destroy its left subtree,then its right subtree,and then the node itself.We must then use the operator ____________________ to deallocate the memory occupied by the node.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
Let T be a binary search tree with n nodes,in which n > 0.The number of key comparisons is approximately O(____________________).
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
After inserting an item in a binary search tree,the resulting binary tree must be a(n)____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
In addition to the inorder,preorder,and postorder traversals,a binary tree can also be traversed level-by-level,which is also known as ____________________ traversal.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
1.current = root;
2.while (current is not NULL or stack is nonempty)
if (current is not NULL)
{
visit current node;
push current onto stack;
current = current->lLink;
}
else
{
current = stack.top();
pop stack;
current = current->rLink; //move to the right child
}
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
The algorithm below describes the nonrecursive ____________________ traversal of a binary tree.
1.current = root;
2.while (current is not NULL or stack is nonempty)
if (current is not NULL)
{
push current onto stack;
current = current->lLink;
}
else
{
current = stack.top();
pop stack;
visit current; //visit the node
current = current->rLink;//move to right child
}
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.