Crawling Before You Walk

Tiffany White,

 

I am reading Data Structures and Algorithms in JavaScript and I’m up to Chapter 8 when we are talking about hash table algorithms.

I had to reread the code examples several times to understand what was happening. Here is some sample code from the book

This code here creates a constructor function called HashTable and several references to other functions that will be used in our regular code instead of this constructor. Easy enough.

We create an Array here that is 137 indices wide. We do this because when we run the hash algorithm we can run into something called collision where two items are hashed to the same value in the hash table. The proper thing is to use a prime number. I am still not sure why.

In these examples we used keys to store data in the array. The key is mapped to a number whose value is mapped from 0 to the size of the array, which in this algorithm is 137 indices in length.

In the next example code we are using ASCII values of letters in the key and adding them. This is the hash function used, using the simpleHash() function we added to the constructor function.

Here in this code we are attempting to run the algorithm using the showDistro() function from the constructor.

The output:

This is where I was stuck. What are those numbers on the left?

I had to reread a few pages back to see that we used an array of 137. These are the positions of the hashed results on the hash table, according to the array size.

Wow.

It also let me know that this part of the book may be too advanced for me; that I should learn more of the code I am currently writing before digging into these types of algorithms.

The first part of the book will inevitably help me with Free Code Camp Algorithm challenges as it goes over exactly the types of methods we use in those challenges, the challenges I burnt myself out over.

So I went back to the gym yesterday. If you are a desk jockey like me, I would suggest going to the gym or at least walking outside everyday or every other day. It helps clear you up, gets your blood flowing, and helps you get the exercise that not only helps in your coding endeavors, but keeps you healthy as well.

As far as keeping a regular coding schedule. Yeah. I need to wake up earlier to do this and right now it is almost 1 am. I plan on coding later today and doing it even when it gets hard or stresses me out. Pushing through those rough patches is key.

 

I am reading Data Structures and Algorithms in JavaScript and I’m up to Chapter 8 when we are talking about hash table algorithms.

I had to reread the code examples several times to understand what was happening. Here is some sample code from the book

This code here creates a constructor function called HashTable and several references to other functions that will be used in our regular code instead of this constructor. Easy enough.

We create an Array here that is 137 indices wide. We do this because when we run the hash algorithm we can run into something called collision where two items are hashed to the same value in the hash table. The proper thing is to use a prime number. I am still not sure why.

In these examples we used keys to store data in the array. The key is mapped to a number whose value is mapped from 0 to the size of the array, which in this algorithm is 137 indices in length.

In the next example code we are using ASCII values of letters in the key and adding them. This is the hash function used, using the simpleHash() function we added to the constructor function.

Here in this code we are attempting to run the algorithm using the showDistro() function from the constructor.

The output:

This is where I was stuck. What are those numbers on the left?

I had to reread a few pages back to see that we used an array of 137. These are the positions of the hashed results on the hash table, according to the array size.

Wow.

It also let me know that this part of the book may be too advanced for me; that I should learn more of the code I am currently writing before digging into these types of algorithms.

The first part of the book will inevitably help me with Free Code Camp Algorithm challenges as it goes over exactly the types of methods we use in those challenges, the challenges I burnt myself out over.

So I went back to the gym yesterday. If you are a desk jockey like me, I would suggest going to the gym or at least walking outside everyday or every other day. It helps clear you up, gets your blood flowing, and helps you get the exercise that not only helps in your coding endeavors, but keeps you healthy as well.

As far as keeping a regular coding schedule. Yeah. I need to wake up earlier to do this and right now it is almost 1 am. I plan on coding later today and doing it even when it gets hard or stresses me out. Pushing through those rough patches is key.

© tiff.RSS