BST Flashcards
(12 cards)
Balanced
A binary tree is balanced only if the height of any given node’s right subtree and left subtree differ by no more than 1
height
The height of a node is the number of nodes from the root to the deepest leaf.
The height of a tree is a height of the root.
size
number of nodes
complete
A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible
proper
A Proper binary tree.is a binary tree in which each node has exactly zero or two children.
Max Heap
heap is a binary tree (not a bst)
complete at all times, so insert left to right without comparison
Max heap the parent is bigger and min heap the parent is smaller.
first insertion is to the left because it’s complete at all times, second is to the right for the same reasons and so on, there’s no comparison for insertion
after each insertion you check if the parent is the min/max constraint is satisfied, if not, swap them
After a swap check the constraint again and swap again until the constraint is satisfied
AVL left rotation
see AVL folder
AVL Right Rotation
see AVL folder
AVL Left-right
See AVL Folder
AVL Right Left
see AVL Folder
Full
A Full binary tree.is a binary tree in which each node has exactly zero or two children AND the leaves are all on the same level, IE proper, balanced, and complete
inorder, preorder, postorder
Inorder: left, root, right
preorder: Root, left, right
Postorder: left, right, post