M13: Quiz - Trees & Heaps

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/45

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:10 PM on 5/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

46 Terms

1
New cards
Binary Search Tree (BST)
A binary tree where left child < parent < right child for every node\n\n
2
New cards
BST inorder traversal
Visits nodes in sorted (ascending) order\n\n
3
New cards
Inorder traversal order
Left subtree → Node → Right subtree\n\n
4
New cards
Preorder traversal
Node → Left subtree → Right subtree\n\n
5
New cards
Postorder traversal
Left subtree → Right subtree → Node\n\n
6
New cards
Level
order traversal
7
New cards
Binary tree height
Maximum number of edges from root to deepest leaf\n\n
8
New cards
BST height example result
Height of BST built from 12, 24, 23, 48, 47 is 3\n\n
9
New cards
Perfect binary tree
A tree where all internal nodes have 2 children and all leaves are at the same depth\n\n
10
New cards
Complete binary tree
All levels filled except possibly last, filled left to right\n\n
11
New cards
Full binary tree
Every internal node has exactly two children\n\n
12
New cards
Perfect binary tree node formula
N = 2^(h+1)
13
New cards
Perfect binary tree leaves formula
2^h leaves at height h\n\n
14
New cards
Perfect binary tree height 3 leaves
8\n\n
15
New cards
Perfect binary tree height 4 nodes
31\n\n
16
New cards
Internal nodes in full binary tree (height 4)
15\n\n
17
New cards
BST remove node case 3 (left child only)
node.parent.replace_child(node, node.left)\n\n
18
New cards
BST replace_child condition
new_child != None\n\n
19
New cards
BST replace_child purpose
Replaces a child node while maintaining parent links\n\n
20
New cards
BST inorder recursive step
BST_print_in_order(node.left)\n\n
21
New cards
BST height function formula
1 + max(left_height, right_height)\n\n
22
New cards
BST search worst case comparisons
height + 1 comparisons\n\n
23
New cards
BST search height 3 worst case
4 comparisons\n\n
24
New cards
BST delete result example
Removing 4 leaves tree rooted at 6 with children 3 and 8\n\n
25
New cards
BST successor
Smallest node in the right subtree\n\n
26
New cards
BST predecessor
Largest node in the left subtree\n\n
27
New cards
Heap
A complete binary tree that satisfies heap property\n\n
28
New cards
Min
heap property
29
New cards
Max
heap property
30
New cards
Heap root location
The root always contains the highest priority element\n\n
31
New cards
Heap remove operation
Removes root and rebalances tree using heapify\n\n
32
New cards
Heap after removal example
Root becomes 60 after removing 77\n\n
33
New cards
Set behavior in Python
Automatically removes duplicates\n\n
34
New cards
Python set add behavior
Adding same element multiple times does not change size\n\n
35
New cards
Python set length example
Adding A, B, C, a, b, c results in 6 elements\n\n
36
New cards
Union operation (set)
Combines all unique elements from both sets\n\n
37
New cards
Set union method behavior
Adds all elements from both sets into one\n\n
38
New cards
BST validity rule
Left subtree < node < right subtree must always hold\n\n
39
New cards
Valid BST example
Root 6 with left 4 and right 8 is a valid BST\n\n
40
New cards
Invalid BST example
Node values violate ordering rule (e.g., right child smaller than root)\n\n
41
New cards
Node parent in BST delete
Parent pointer is used to reconnect children after deletion\n\n
42
New cards
BST remove node types
Leaf, one child, two children, root case\n\n
43
New cards
BST remove root case
Special handling required when deleting root node\n\n
44
New cards
Tree node relationship
Each node has at most one parent and up to two children\n\n
45
New cards
Binary tree structure
A tree where each node has at most two children\n\n
46
New cards
Heap vs BST difference
Heap is partially ordered, BST is fully ordered\n\n