### Bianca Gandolfo PRO

Slide decks for learning JavaScript

@BiancaGando

@BiancaGando

JavaScript objects are hash tables

Represented as key/value pairs

A hashing function maps the key to an index

@BiancaGando

A hashing function takes an input of any size and returns a hash code identifier of a fixed size.

myHash("This is a really long string") => 7

myHash("I'm pretty short") => 11

@BiancaGando

`//Code here`

Attribution: Jorge Stolfi, 10 April 2009, CC BY-SA 3.0 https://commons.wikimedia.org/wiki/File:Hash_table_3_1_1_0_1_0_0_SP.svg

@BiancaGando

@BiancaGando

myHashTable.set(prop, val)

myHashTable.get(prop)

myHashTable.remove(prop)

Storage

Hashing Function

@BiancaGando

`//Code here`

Things to consider:

What if there are collisions?

**Pros**

- Adding items is fast: O(1)
- Removing items is fast: O(1)
- Accessing key'd item is fast: O(1)

**Cons**

- No preserved order

@BiancaGando

ES6 gives us a map data structure that is like a hash table but has a preserved order! Read more here

@BiancaGando

@BiancaGando

**You know how to create a class in the pseudoclassical style!**

Now you could...

... learn how to subclass and extend your classes

... learn how to implement a class in ES6

... check out this open source resource on data structures/algos in ES6

@BiancaGando

**You know how to estimate runtime complexity of algorithms and operations on your data structures. **

Now you could...

... jump into computational complexity theory to learn how to further classify problems by difficulty so you can use the terms NP-Complete, NP-Hard and sound really cool.

... learn formal time complexity calculations and proofs

@BiancaGando

**You learned elementary sorts and recursive sorts**

Now you could...

... learn a non-comparison sort like Radix sort

... learn how to combine insertion sort with merge sort to create Timsort

... have fun with some sorts because they have funny names like gnome sort, stooge sort and bogosort

@BiancaGando

**You learned linked lists and n-ary trees**

Now you could...

... learn how to use a trie/prefix tree to autocomplete text.

... create a dialog tree and have conversations with it when you are lonely.

... create a scavenger hunt game with your linked list.

@BiancaGando

**You learned basic operations for binary search trees.**

Now you could...

... balance your BST with the DSW algorithm or

... create self-balanced BSTs like an AVL or red-black tree

... learn the difference between a binary tree and a binary heap then implement your own heap sort!

@BiancaGando

**You learned how to represent and explore graphs.**

Now you could...

... take it to the next level by studying graphs in a discrete mathematics class

... apply topological sort to figure out what classes you need to take, in what order to graduate

... Calculate shortest paths between two cities using Dijkstra's algorithms

... Learn how to find MSTs that are central to data mining using Prim's algorithm.

@BiancaGando

**You learned about hashing and created your own hash tables...**

Now you could...

... ... deepen your understanding of git/version control works using trees, hashes and more

... get curious about bloom filters are used in caching

... explore hashing in security contexts starting with a hash tree used in P2P networks

... consider the complexity of a distributed hash table

By Bianca Gandolfo

Day 4

- 3,885