Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full Stack/Javascript: HashMap Assignment: LinkedList usage instructions unclear #29290

Open
3 tasks done
ctcleary opened this issue Jan 7, 2025 · 0 comments
Open
3 tasks done

Comments

@ctcleary
Copy link

ctcleary commented Jan 7, 2025

Checks

Describe your suggestion

On the "Project: HashMap" this paragraph appears (bolding mine).

"You might find yourself confusing keys with hash codes while accessing key-value pairs later. We would like to stress that the key is what your hash function will take as an input. In a way, we could say that the key is important for us only inside the hash function, as we never access a bucket directly with the key. Instead, we always do so with the hash code."

When the concept of duplicate keys that might produce the same hash comes up, the assignment directs the learner to the previous page's Dealing with collisions section, which tells the learner to use a LinkedList inside the bucket, This part was a HUGE hurdle for me until I went to TOP Discord and got help. Because of the bolded statement in the above paragraph, I was under the impression that you were not "supposed to" store the original key string anywhere in the HashMap structure.

"Recall that collisions occur when TWO DIFFERENT keys generate the same hash code and get assigned to the same bucket. (e.g. Rama and Sita are both hashed to 3, so 3 becomes a location for Rama AND Sita. However, we know that this is not an update because the keys are different). Review the dealing with collisions section of the previous lesson to find a way to handle our collisions."

I propose adding a clarifying parenthetical because the linked-to section is inadequate in its explanation, that reads something like: "(In this case, storing the original string keys -- like Rama and Sita -- in the LinkedList will be required to ensure data is not accidentally overwritten.)"

Or maybe the first line about it "only" being important inside the hash() function needs to change?

Path

Node / JS

Lesson Url

https://www.theodinproject.com/lessons/javascript-hashmap

(Optional) Discord Name

@ctcsaw / "Connor Thomas Cleary"

(Optional) Additional Comments

Since I haven't contributed before, I didn't feel comfortable just opening a PR without discussing it here first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant