Data Structures, unit: Trees and Binary Search Trees. Core concepts, terminology, and worked-example cues a college student meets for this unit, building on prior units without repeating them. Front: a term, concept, or short problem cue. Back: the definition, explanation, or answer.
30 cards · basic cards · AI-written, checked twice. Edit anything.
- What is a tree, as a data structure?
- A hierarchical structure of nodes connected by edges, with one root and no cycles
- What is the root of a tree?
- The topmost node, with no parent
- What is a leaf node?
- A node with no children
- What is the height of a tree?
- The length of the longest path from the root to a leaf
- What is a binary tree?
- A tree where each node has at most two children
- What is a binary search tree (BST)?
- A binary tree where each node's left subtree contains smaller values and right subtree contains larger values
- What is the time complexity of searching a balanced binary search tree?
- O(log n)
- What is the time complexity of searching an unbalanced (degenerate) binary search tree?
- O(n) in the worst case
- What is tree traversal?
- Visiting all nodes of a tree in a systematic order
- What is inorder traversal?
- Visiting left subtree, then the node, then right subtree
- What is preorder traversal?
- Visiting the node first, then left subtree, then right subtree
- What is postorder traversal?
- Visiting left subtree, then right subtree, then the node last
- What does an inorder traversal of a binary search tree produce?
- The values in sorted order
- What is a balanced binary tree?
- A tree where the height difference between left and right subtrees is minimized at every node
- What is an AVL tree?
- A self-balancing binary search tree that maintains balance after every insertion or deletion