Chapter 23 -Trees
List the steps of a postorder traversal of a binary tree.
1. Visit all the nodes in the root's left subtree 2. Visit all the nodes in the root's right subtree 3. visit the root
List the steps of an inorder traversal of a binary tree.
1. Visit all the nodes in the root's left subtree 2. Visit the root 3. Visit all the nodes in the roots right subtree
List the steps of a preorder traversal of a binary tree.
1. Visit the root 2. Visit all the nodes in the root's left subtree 3. Visit all the nodes in the root's right subtree
How many nodes are in a full binary tree of height 8?
2^8 - 1 or 256 - 1 = 255
How many nodes are in a full binary tree of height 5?
31
What is the height of a complete tree that contains 11 nodes?
4
A level-order traversal of a binary tree is an example of a depth-first traversal.
False
Completely balance binary trees are not necessarily full.
False
Every general tree is an n-ary tree.
False
The path between a tree's root and any other node is not unique.
False
An example of a data organization that is hierarchical is a(n)
Family tree. University administration structure. File directories
A tree is a set of _____ connected by edges that indicate the relationships among the nodes.
Nodes
A _____ is a set of nodes connected by edges that indicate the relationships among the nodes.
Tree
A preorder traversal of a binary tree is an example of a depth-first traversal.
True
A subtree of a tree is a subtree of the tree'sroot.
True
All leaves in a full binary tree are on the same level.
True
All nodes in a balanced binary tree are balanced.
True
An inorder traversal is not well defined for a general tree.
True
Every node in a binary search tree is the root of a binary search tree.
True
In a tree, nodes are arranged in levels that indicate the nodes' hierarchy.
True
In a tree, the root is the only node that has no parent.
True
The height of a tree equals the number of nodes along the longest path between the root and a leaf.
True
A subtree of a node is a tree rooted at
a child of that node
A node in a binary tree whose subtrees differ in height by no more than 1 is known as a(n) _____ node.
balanced
A tree in which each node may have at most two children is called a(n) _____ tree.
binary
The nodes at each successive level of a tree are called _____.
children
The nodes in a binary search tree contain _____ objects.
comparable
When a binary tree is full to its next-to-last level and its leaves on the last level are filled from left to right, the tree is said to be
complete
A tree is a set of nodes connected by _____ that indicate the relationships among the nodes.
edges
When a binary tree of height h has all of its leaves at level hand every nonleaf has exactly two children, the tree is said to be
full
A tree in which each node may have an arbitrary number of children is called a(n) _____ tree.
general
The number of levels in a tree is called the
height
A family tree is typically organized into a(n) _____ order.
hierarchical
When you classify data into groups and subgroups, you are using a(n) _____ order.
hierarchical
In a _____ traversal of a binary tree, you visit the root of a binary tree between visiting the nodes o the root's subtrees.
inorder
A node with no children is called a(n) _____.
leaf
In a _____ traversal of a binary tree, you begin at the root and visit nodes one level at a time.
level order
What is the height of a complete tree that contains 18 nodes?
log2(18+1) rounded up is 5
The height of a complete tree that has n nodes is
log2(n+1)
The height of a full tree that has n nodes is
log2(n+1)
A _____ is a complete binary tree such that each node in the tree contains a Comparable object that is greater than or equal to the objects in the node's descendants.
maxheap
A tree in which each node may have no more than n children is called a(n) _____ tree.
n-ary
A node that has children is called a(n) _____.
nonleaf interlor node
A node that has children is a(n) _____.
parents
In a _____ traversal of a binary tree, you visit the root of a binary tree after you visit the root's subtrees.
postorder
In a _____ traversal of a binary tree, you visit the root node before you visit the root's subtrees.
preorder
At the top level of a tree is a single node called the _____.
root
The _____ node is the only node that has no parent.
root
Nodes that are children of the same parent node are called _____.
siblings
Any node and its descendants form a _____ of the original tree.
subtree
A binary tree has at most two children called
the left child the right child