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

addressed issue 1033, changed while to if in LinkedList and add new b… #1037

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
addressed issue 1033, changed while to if in LinkedList and add new b…
…efore Array in HashTable constructor
tmichell13 committed May 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 085bb2973e89b8fe23d987c428a7793345c08634
2 changes: 1 addition & 1 deletion src/data-structures/hash-table/HashTable.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ export default class HashTable {
*/
constructor(hashTableSize = defaultHashTableSize) {
// Create hash table of certain size and fill each bucket with empty linked list.
this.buckets = Array(hashTableSize).fill(null).map(() => new LinkedList());
this.buckets = new Array(hashTableSize).fill(null).map(() => new LinkedList());

// Just to keep track of all actual keys in a fast way.
this.keys = {};
2 changes: 1 addition & 1 deletion src/data-structures/linked-list/LinkedList.js
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ export default class LinkedList {

// If the head must be deleted then make next node that is different
// from the head to be a new head.
while (this.head && this.compare.equal(this.head.value, value)) {
if (this.head && this.compare.equal(this.head.value, value)) {
deletedNode = this.head;
this.head = this.head.next;
}