1 of 12

Trees, Sets, Dictionaries, and MultiDictionaries

Data Structures Part 2

2 of 12

Binary Tree - Vocab

Root

Parent

Child (Left / Right)

Sibling

Grandparent/child

Uncle / Aunt

Cousin

Leaf Node

Internal Node

Path

Height

Complete

Full

3 of 12

Binary Search Tree (BST)

4 of 12

BST Operations

Where would you add the number 2?

Where would you add the number 4?

How would you find the value 13?

Why is this called a Binary Search Tree?

5 of 12

BST Remove

6 of 12

BST Remove

What if you wanted to remove 2?

7 of 12

BST Remove

Inorder Successor / Predecessor

8 of 12

Transversals

Level Order (Usually implemented using a Queue!)

Pre Order: (root, left, right)

In Order (left, root, right)

Post Order: (left, right, root)

9 of 12

Fun BST Questions

1) How can you organize the data in a BST so it is the most efficient? So it is the least efficient?

2) How many different ways can a data set of n values be organized in a BST?

10 of 12

Set

  • Collections of values
  • Duplicates are not allowed!

11 of 12

Dictionary

12 of 12

MultiDictionary

Dictionary where each key associates with multiple values

Adding values does not remove old values