Prev: W2, Next: W4
Links: Zoom, TopHat (010339, or Form), Calculator:
Slide:



# Adelson-Velsky-Landis Trees

📗 Self-balancing binary search tree (alternative to RBTs)
📗 Uses rotations to maintain balance: goal is to keep \(H\) height of tree with \(N\) nodes growing in \(O\left(\log\left(N\right)\right)\).
📗 Visualization: Link.



# AVL Tree Insertion

📗 Insert new value using regular BST insertion algorithm.
📗 Check if tree is out of balance, and rebalance if it is.
➩ Balance Factor = height of left subtree - height of right subtree.
➩ A node is balanced if \(\left| BF \right| < 2\).
➩ Sign tells us direction of imbalance.
➩ A tree is balanced if every node in the tree is balanced.

# AVL Tree Example

ID:
📗 [1 point] Compute the balance factor for each node.
➩ \(+1\) by clicking on the right side of a node and \(-1\) by clicking on the left side of a node. 
 
📗 List of nodes:

# AVL Tree Insert Example

ID:
📗 [1 point] Insert the following nodes: (click the "Insert" square to insert this node to the BST).
➩ Rotate the tree from A to B by dragging A to B in the diagram and \(+1\) by clicking on the right side of a node and \(-1\) by clicking on the left side of a node.

📗 List of nodes:

# AVL Tree Insert Another Example

📗 Another example from Campus section: 20, 10, 5, 4, 7, 14, 30, 22, insert 8.
📗 Compare AVL Link and BST Link.



# AVL Tree Deletion [Not on Midterm]

📗 Deletion is similar to insertion (regular BST deletion + rebalance).



# Version Control

📗 Stores different (incremental) versions of files containing source code.
📗 Git Workflow:
➩ Working directory -> add -> Staging -> commit -> Local repository -> push -> Remote repository.
➩ Remote repository -> fetch, pull -> Local repository -> checkout -> Working directory.
📗 Git Simulator and Visualization: Link (CS320), Link.



# Readings

📗 Introduction to Version Control: Link
📗 Getting Started with Git: Link
📗 Recording Changes with Git: Link
📗 Branches and Merging in Git: Link
📗 Working with Remotes in Git: Link



📗 Notes and code adapted from the course taught by Professor Florian Heimerl and Ashley Samuelson.
📗 Please use Ctrl+F5 or Shift+F5 or Shift+Command+R or Incognito mode or Private Browsing to refresh the cached JavaScript.
📗 You can expand all the examples and demos: , or print the notes: .
📗 If there is an issue with TopHat during the lectures, please submit your answers on paper (include your Wisc ID and answers) or this Google Form at the end of the lecture.

Prev: W2, Next: W4





Last Updated: November 25, 2025 at 1:46 AM