Bianca Gandolfo PRO
Slide decks for learning JavaScript
@BiancaGando
@BiancaGando
@BiancaGando
Constructor:
- storage
- root
Methods:
search(key): This searches for the key in the tree and returns true if it exists and returns false if the node doesn't
min/max: This returns the min or max value/key in the tree
remove(key): This removes the key from the tree
A linked list is a tree structure with only one child per node.
Each node in the list contains:
@BiancaGando
@BiancaGando
@BiancaGando
@BiancaGando
@BiancaGando
1. Constructor Function
- storage
- head
2. Methods
- .addToTail(val) //adds node to tail
- .remove(node) //removes node from list & returns it
@BiancaGando
//Constructor
//Add to tail
//Remove node
@BiancaGando
//Constructor
//Add a child
@BiancaGando
Adding nodes: O(1)*
Removing nodes: O(1)*
Searching: O(n)
*when you have a reference to the node.
@BiancaGando
Fast addition
Fast removal
Slow look-up without reference to the node
@BiancaGando
Create a scavenger hunt game using a Linked List.
Let's discuss how you think we may go about doing that before diving in.
@BiancaGando
By Bianca Gandolfo
Day 2