Free Online Flashcard Deck

07 Trees and Binary Search Trees Free Online FlashCards

Study 07 Trees and Binary Search Trees with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is a tree in data structures?

Back

A tree is a hierarchical structure of nodes connected by edges with no cycles; there is exactly one path between the root and any other node.

02
Front

How do depth and height differ in a tree?

Back

A node’s depth is its number of edges from the root. A node’s height is the number of edges on its longest downward path to a leaf.

03
Front

What defines a binary tree?

Back

A binary tree is a tree in which each node has at most two children, designated as its left and right subtrees.

04
Front

What is a full binary tree?

Back

In a full binary tree, every node has either zero children or two children.

05
Front

What is a complete binary tree?

Back

A complete binary tree has every level full except possibly the last, and its last level is filled from left to right.

06
Front

What is the preorder sequence for the example tree?

Back

Preorder visits the root, then the left subtree, then the right subtree. For the example tree, the sequence is A, B, D, E, C, F.

07
Front

Why is inorder traversal important for a BST?

Back

Inorder traversal visits the left subtree, the node, then the right subtree. In a BST, this produces keys in ascending order.

08
Front

When is postorder traversal especially useful?

Back

Postorder visits the left subtree, the right subtree, and then the node. It is useful when descendants must be processed before their parent, such as freeing nodes.

09
Front

How does level-order traversal visit nodes?

Back

Level-order traversal visits nodes one level at a time from top to bottom, usually left to right, and is commonly implemented with a queue.

10
Front

What ordering property defines a BST?

Back

For each node with key K, every key in its left subtree is smaller than K and every key in its right subtree is larger, under the stated duplicate policy.

11
Front

What path finds 7 in the example BST?

Back

The search path is 8 → 3 → 6 → 7. Each comparison selects the left or right subtree that could contain the target.

12
Front

Where is 5 inserted in the example BST?

Back

Inserting 5 follows 8 → 3 → 6 → 4; because 5 is greater than 4, it becomes the right child of 4.