Questions Chapter 8 Flashcards
Trees consist of ______ connected by ______.
Trees consist of nodes connected by edges.
In a binary tree, a node has at most ____ children.
two
In a binary tree, all the nodes that are _____ descendants of Node A have key values _____ than A; all the nodes that are A’s _____ descendants have key values ______ than or equal to A.
left descendants have key values less than A, right descendants have key values greater than or equal to A.
Trees perform searches, insertions, and deletions in ______ time.
O(log N) time
An unbalanced tree is one whose root has many more ______ descendants than _____ descendants or vice-versa.
left than right, right than left descendants
Insertion involves finding the place to insert the new node and then changing a _______ field in its new _______ to refer to it.
change a child field in its new parent to refer to it
An ________ traversal visits nodes in order of ascending keys.
inorder traversal
When a node has ____ child/children, it can be deleted by setting the _____ field in its parent to null.
zero children, set child field in parent to null.
When a node has _____ child/children, it can be deleted by setting the _______ field in its parent to point to its _______.
one child, set child field in parent to its child.
When a node has ______ child/children, it can be deleted by replacing it with its successor.
two children
The successor to node A can be found by finding the ________ node in the subtree whose ______ is A’s _____ child.
find the minimum node in the subtree whose root is A’s right child.
Insertion and deletion in a tree require what big O time?
O(logN)
A binary tree is a search tree if:
a. every non-leaf node has children whose key values are less than (or equal to) the parent.
b. every left child has a key less than the parent and every right child has a key greater than (or equal to) the parent
c. in the path from the root to every leaf node, the key of each node is greater than (or equal to ) the key of its parent
d. a node can have a maximum of two children
b. every left child has a key less than the parent and every right child has a key greater than (or equal to) the parent.
True or False: Not all trees are binary trees.
True
In a complete binary tree with 20 nodes, and the root considered to be at level 0, how many nodes are there at level 4?
5