diff --git a/src/data-structures/hash-table/HashTable.js b/src/data-structures/hash-table/HashTable.js index b8b523ea..33613125 100644 --- a/src/data-structures/hash-table/HashTable.js +++ b/src/data-structures/hash-table/HashTable.js @@ -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 = {}; diff --git a/src/data-structures/linked-list/LinkedList.js b/src/data-structures/linked-list/LinkedList.js index ba7d0e3e..79783525 100644 --- a/src/data-structures/linked-list/LinkedList.js +++ b/src/data-structures/linked-list/LinkedList.js @@ -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; }