Deck 13: Trees

Full screen (f)
exit full mode
Question
The height of a tree and the depth of a tree are different.
Use Space or
up arrow
down arrow
to flip the card.
Question
Which of the following traversals visits the nodes that are closer to the top of the tree before visiting those that are closer to the bottom?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Question
What property of the tree does its order specify?

A) maximum height
B) maximum number of leaves
C) maximum number of internal nodes
D) maximum number of edges
E) maximum number of children per node
Question
In a full tree, all leaves are at the same level.
Question
Which of the following traversals visits the root after visiting the left and right subtrees?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Question
Since trees are nonlinear structures, it is impossible to implement them using an array.
Question
In a tree, a node that does not have any children is called a leaf.
Question
One method of implementing a tree using an array involves storing the child of the element at the index n in the array at indexes ______________________________ .

A) n+1 and n+2
B) 2n and 22n
C) 2n+1 and 2n+2
D) n-1 and n-2
E) none of the above will work
Question
A tree in which every node can have at most n children is referred to as a __________________ tree.

A) binary
B) ternary
C) n-ary
D) general
E) graph
Question
A full binary tree of height n has _________________ leaves.

A) 2n
B) 3n
C) 2n
D) 2(n+1)
E) 3(n+1)
Question
Which of the following best describes a balanced tree?

A) A balanced trees has all nodes at exactly the same level.
B) A balanced tree has no nodes at exactly the same level.
C) A balanced tree has half of the nodes at one level and half the nodes at another level.
D) A balanced tree has all of the nodes within one level of each other.
E) none of the above correctly describe a balanced tree.
Question
Which of the following traversals never visits the root?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Question
A balanced binary tree with m elements will have height ______________ .

A) 2m
B) 2m
C) logm 2
D) log2 m
E) none of the above
Question
A _________________ can be used as the basis for an expert system.

A) queue
B) stack
C) ternary tree
D) 4-ary tree
E) decision tree
Question
Which of the following traversals visits the root before visiting the left and right subtrees?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Question
Which of the following traversals is implemented using a queue as a supporting data structure?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above are implemented using a queue
Question
Which of the following tree traversals traverses the subtrees from left to right and then visits the root?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Question
Which of the following traversals is not easily implemented recursively?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) all of the above are easily implemented recursively
Question
A _________________ is a nonlinear structure in which elements are organized into a hierarchy.

A) graph
B) tree
C) queue
D) stack
E) linked-list
Question
A binary tree is a tree in which any node can have at most two children.
Question
Suppose we are implementing a binary tree as a linked structure of BinaryTreeNode objects. Write a method that will print out all of the nodes of tree via an inorder traversal. You may assume that the class has a reference to a BinaryTreeNode object called root. In addition, your method may take a reference to a BinaryTreeNode object as a parameter.
Question
In an inorder traversal, the root is the first element to be visited in the tree.
Question
How many leaves will be contained in a full binary tree of height 5?
Question
A decision tree cannot be used as the basis for an expert system.
Question
What does it mean for a tree to be balanced?
Question
In a postorder traversal, the root is the last element visited in the tree.
Question
What is a disadvantage of implementing a tree as an array using computed links?
Question
Suppose we are implementing a binary tree as a linked structure of BinaryTreeNode objects. Write a method that will print out all of the nodes of tree via a preorder traversal. You may assume that the class has a reference to a BinaryTreeNode object called root. In addition, your method may take a reference to a BinaryTreeNode object as a parameter.
Question
Explain how a binary tree can be implemented using an array.
Question
In an inorder traversal, the elements of a tree are visited in order of their distance from the root.
Question
What are the leaves of a tree?
Question
If a tree has order 4, what does this mean?
Question
What might be the difference between a complete binary tree and a full binary tree?
Question
Explain the implementation of an postorder traversal.
Question
There are four basic ways to traverse a tree, and they are all implemented recursively.
Question
What is a decision tree?
Question
Explain the implementation of a level-order traversal of a tree.
Question
Consider the following tree structure.
A
/ \
B C
/ \ \
D E F
In what order will the nodes be visited using a postorder, a preorder, an inorder, and a level-order traversal?
Question
What is an internal node in a tree?
Question
What is the root of a tree?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 13: Trees
1
The height of a tree and the depth of a tree are different.
False
Explanation: Height and depth are synonyms in the context of trees.
2
Which of the following traversals visits the nodes that are closer to the top of the tree before visiting those that are closer to the bottom?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
D
Explanation: The level-order traversal visits each node at each level of the tree from the top to the bottom.
3
What property of the tree does its order specify?

A) maximum height
B) maximum number of leaves
C) maximum number of internal nodes
D) maximum number of edges
E) maximum number of children per node
E
Explanation: The order of a tree represents the maximum number of children per node.
4
In a full tree, all leaves are at the same level.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following traversals visits the root after visiting the left and right subtrees?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
Since trees are nonlinear structures, it is impossible to implement them using an array.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
In a tree, a node that does not have any children is called a leaf.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
One method of implementing a tree using an array involves storing the child of the element at the index n in the array at indexes ______________________________ .

A) n+1 and n+2
B) 2n and 22n
C) 2n+1 and 2n+2
D) n-1 and n-2
E) none of the above will work
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
A tree in which every node can have at most n children is referred to as a __________________ tree.

A) binary
B) ternary
C) n-ary
D) general
E) graph
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
A full binary tree of height n has _________________ leaves.

A) 2n
B) 3n
C) 2n
D) 2(n+1)
E) 3(n+1)
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following best describes a balanced tree?

A) A balanced trees has all nodes at exactly the same level.
B) A balanced tree has no nodes at exactly the same level.
C) A balanced tree has half of the nodes at one level and half the nodes at another level.
D) A balanced tree has all of the nodes within one level of each other.
E) none of the above correctly describe a balanced tree.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following traversals never visits the root?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
A balanced binary tree with m elements will have height ______________ .

A) 2m
B) 2m
C) logm 2
D) log2 m
E) none of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
A _________________ can be used as the basis for an expert system.

A) queue
B) stack
C) ternary tree
D) 4-ary tree
E) decision tree
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following traversals visits the root before visiting the left and right subtrees?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following traversals is implemented using a queue as a supporting data structure?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above are implemented using a queue
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following tree traversals traverses the subtrees from left to right and then visits the root?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) none of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following traversals is not easily implemented recursively?

A) Preorder
B) Inorder
C) Postorder
D) Level-order
E) all of the above are easily implemented recursively
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
A _________________ is a nonlinear structure in which elements are organized into a hierarchy.

A) graph
B) tree
C) queue
D) stack
E) linked-list
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
A binary tree is a tree in which any node can have at most two children.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
Suppose we are implementing a binary tree as a linked structure of BinaryTreeNode objects. Write a method that will print out all of the nodes of tree via an inorder traversal. You may assume that the class has a reference to a BinaryTreeNode object called root. In addition, your method may take a reference to a BinaryTreeNode object as a parameter.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
In an inorder traversal, the root is the first element to be visited in the tree.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
How many leaves will be contained in a full binary tree of height 5?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
24
A decision tree cannot be used as the basis for an expert system.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
What does it mean for a tree to be balanced?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
In a postorder traversal, the root is the last element visited in the tree.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
What is a disadvantage of implementing a tree as an array using computed links?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
Suppose we are implementing a binary tree as a linked structure of BinaryTreeNode objects. Write a method that will print out all of the nodes of tree via a preorder traversal. You may assume that the class has a reference to a BinaryTreeNode object called root. In addition, your method may take a reference to a BinaryTreeNode object as a parameter.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
Explain how a binary tree can be implemented using an array.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
In an inorder traversal, the elements of a tree are visited in order of their distance from the root.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
What are the leaves of a tree?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
If a tree has order 4, what does this mean?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
What might be the difference between a complete binary tree and a full binary tree?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
Explain the implementation of an postorder traversal.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
There are four basic ways to traverse a tree, and they are all implemented recursively.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
What is a decision tree?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
Explain the implementation of a level-order traversal of a tree.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
Consider the following tree structure.
A
/ \
B C
/ \ \
D E F
In what order will the nodes be visited using a postorder, a preorder, an inorder, and a level-order traversal?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
What is an internal node in a tree?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
What is the root of a tree?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.