Trees - Chapter 5 Flashcards
In a list, each node has up to one successor. In a blank, each node has up to two children, known as a left child and a right child.
binary tree
Blank: A tree node with no children.
Leaf
Blank: A node with at least one child.
Internal node
Blank A node with a child is said to be that child’s blank.
Parent:
A node’s blank include the node’s parent, the parent’s parent, etc., up to the tree’s root.
ancestors
Blank: The one tree node with no parent (the “top” node).
Root
The link from a node to a child is called an blank.
edge
A node’s blank is the number of edges on the path from the root to the node
depth
The root node thus has depth blank.
0
All nodes with the same depth form a tree blank
level
A tree’s blank is the largest depth of any node.
height
A tree with just one node has height blank
0
A binary tree is blank if every node contains 0 or 2 children.
full
A binary tree is blank if all levels, except possibly the last level, contain all possible nodes and all nodes in the last level are as far left as possible.
complete
A binary tree is blank, if all internal nodes have 2 children and all leaf nodes are at the same level.
perfect
Trees are commonly used to represent blank
hierarchical data
A blank can represent files and directories in a file system, since a file system is a hierarchy.
tree
Blank is a technique of repeatedly separating a region of space into 2 parts and cataloging objects contained within the regions.
Binary space partitioning (BSP)
A blank is a binary tree used to store information for binary space partitioning.
BSP tree
Each node in a BSP tree contains information about a blank and which objects are contained in the region.
region of space
In graphics applications, a BSP tree can be used to store all objects in a blank. The BSP tree can then be used to efficiently determine which objects must be rendered on screen.
multidimensional world
Most of the tree data structures discussed in this book serve to store a collection of values. Numerous tree types exist to store blank in a structured way that allows for fast searching, inserting, and removing of values.
data collections
An especially useful form of binary tree is a blank, which has an ordering property that any node’s left subtree keys ≤ the node’s key, and the right subtree’s keys ≥ the node’s key
binary search tree (BST)
To search nodes means to find a node with a desired key, if such a node exists. A BST may yield faster searches than a blank Searching a BST starts by visiting the root node (which is the first currentNode below):
list.
Searching a BST in the worst case requires H + 1 comparisons, meaning blank comparisons, where H is the tree height.
O(H)
A major BST benefit is that an N-node binary tree’s height may be as small as blank, yielding extremely fast searches.
O(logN)
A binary tree’s height can be minimized by keeping all levels full, except possibly the last level. Such an “all-but-last-level-full” binary tree’s height is blank
H = floor(log2 N)
BST defines an ordering among nodes, from smallest to largest. A BST node’s blank is the node that comes after in the BST ordering, so in A B C, A’s successor is B, and B’s successor is C.
successor