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




# Course Overview

📗 TopHat in-class quiz: participation points, 10%, use Google Form if TopHat is not working or missed a lecture due to travel or emergencies.
📗 Homework (Activities + Quizzes on PrarieLearn): same as the Campus sections, but different due dates.
📗 Project: same as the Campus sections, also different due dates.
📗 Exam: temporary dates on course website.
📗 Note for Epic section: Generative AI and Large Language Models (LLMs) are not allowed in the Campus sections, but you are encouraged to use them for all assignments and exams, but please remember to give proper attribution.
📗 (new) Experimental competitive projects: can be used to replace exam or project grades (i.e. exams are optional).



# Course Content

📗 Lectures: efficient data structure and algorithms.
➩ Binary Search Trees: Red-Black Tree, AVL Trees, B-Trees.
➩ Sets and Graphs: Minimum Spanning Tree, Shortest Path.
➩ Other: Linear Sorts, Hash Tables, Skip Lists.
📗 Projects: work in a team on larger projects and test teammate's code.
➩ Command Line Tools: bash, ssh, git
➩ JUnit Tests
➩ Web Development: HTML, CSS, JavaScript



# Binary Search Tree (BST)

📗 Every node has 0 or 1 parent and 0, 1, or 2 children.
📗 The height of a tree is the number of nodes from the root to the tree's deepest leaf. (For this course, use the number of nodes, NOT the number of edges.)
➩ Visualization: .

# BST Small Example [TopHat]

ID:
📗 [1 point] Search for the value of the item associated with in the following BST.

📗 Click on the current node to list the item: .

# BST Large Example [TopHat]

ID:
📗 [1 point] Search for the value of the item associated with in the following BST.

📗 Click on the current node to list the item: .



# Tree Traversals

📗 Values in a tree can be converted into a list by:
➩ In-order.
➩ Pre-order.
➩ Post-order.
➩ Level-order.

# BST Traversal Example [TopHat]

ID:
📗 [1 point] List all the items (keys and values) of the BST using .

📗 Click on the current node to list the item: .



# BST Operations

📗 Number of nodes in a BST: \(N\), height of a BST: \(H\).
📗 Search a value: \(O\left(H\right)\)
📗 Inserting value into tree: \(O\left(H\right)\)
📗 Deleting value from tree (leaf nodes): \(O\left(H\right)\)
📗 Deleting value from tree (one child): \(O\left(H\right)\)
📗 Deleting value from tree (two children): \(O\left(H\right)\)

# BST Insert and Delete Example [TopHat]

ID:
📗 [1 point] Delete the item associated with from the tree. The insertion order is: .






# Insertion Sequence

📗 When the height of the BST is \(H\), then the number of nodes is:
➩ Minimum: \(N\).
➩ Maximum: \(2^{H} - 1\).
📗 When the number of nodes is \(N\), the height of a BST is:
➩ Minimum: \(\log_{2}\left(N + 1\right)\) or \(O\left(\log\left(N\right)\right)\).
➩ Maximum: \(N\).

# BST Height Example [TopHat]

ID:
📗 [1 point] What is the minimum and maximum heights of the tree with these nodes. The insertion order is: .

The height of the tree is: .  




# Tree Rotation

📗 Goal: manipulate tree structure, for example, so that the BST stays balanced (self balancing).
➩ Left rotation.
➩ Right rotation.
📗 Next lecture: Red-Black Tree and AVL Tree (rotate to balance the tree).

# Tree Rotation Example [TopHat]

ID:
📗 [1 point] Rotate the root of the tree to the .

 



# Readings

📗 Notes from the Campus section: Link
📗 Bash tutorial: 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: W1, Next: W2





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