Free Online Flashcard Deck

6 Trees and Binary Search Trees Free Online FlashCards

Study 6 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?

Back

A tree is a hierarchical, acyclic data structure made of nodes connected by edges, accessed from a distinguished root.

02
Front

What is a node's depth?

Back

A node's depth is the number of edges from the root to that node. With root depth 0, node D has depth 2 in the example tree.

03
Front

What defines a binary tree?

Back

A binary tree is a tree in which each node has at most two children, conventionally called the left child and right child.

04
Front

What is a full binary tree?

Back

A full binary tree has either zero children or exactly two children at every node.

05
Front

How many nodes are in a perfect tree of height hh?

Back

A perfect binary tree of height hh has exactly 2h+1−12^{h+1}-1 nodes.

06
Front

What is preorder traversal order?

Back

Preorder visits the current node, then the left subtree, then the right subtree: node-left-right.

07
Front

Why is inorder traversal useful for a BST?

Back

For a binary search tree, inorder traversal visits keys in sorted order because it processes left subtree, node, then right subtree.

08
Front

How does level-order traversal process nodes?

Back

Level-order traversal processes nodes by increasing depth, typically using a queue.

09
Front

What is the base case for recursive node counting?

Back

The recursive node-counting algorithm returns 00 for an empty subtree and otherwise returns 1+count(left)+count(right)1+count(left)+count(right).

10
Front

What is unordered binary-tree search complexity?

Back

Searching an unordered binary tree has worst-case time complexity O(n)O(n), because both subtrees may need to be examined.

11
Front

What ordering rule defines a BST?

Back

A BST requires every key in the left subtree to be less than the node's key and every key in the right subtree to be greater.

12
Front

What is the time complexity of BST search?

Back

BST search takes O(h)O(h), where hh is tree height, because each comparison follows only one child.