JavaScript Data Structures - 29 - Hash Table Implementation

preview_player
Показать описание

📱 Follow Codevolution

Hash Table Implementation
JavaScript Data Structures
Data Structures in JavaScript
Рекомендации по теме
Комментарии
Автор

Best Hash Table Implementation for JavaScript Thank you :)

prashantindurkar
Автор

When we use new Array(50), this creates a "sparse array" - i.e. an array with a fixed length, and its values are empty - also see MDN docs on Sparse Arrays.

With fixed length arrays you can safely use: delete array[index]
This is an alternative way to remove the value at the specified index without changing the size of the array.

Ctrl_Alt_Elite
Автор

Very straight forward and simple explanation 😃

muzammilkhan
Автор

Thanks very much, this is a perfect tutorial for js, i hope to continue some content like binary search tree, AVL please.

muhammedmohsen
Автор

Hello Sir, The Content you upload is loved by all the viewer keep it going.Requesting you to start an Blockchain Tutorial too.Thank You

atteshamshaikh
Автор

Can you make video on microfrontend react

anandnadart
Автор

HashTable will fail if you set key = GOD and add another Key DOG, because it wil give the same hash/index

SumitRawat-sx
Автор

It's complicated
This is better:

class HashTable {
constructor() {
this.values = {};
this.length = 0;
this.size = 0;
}

calculateHash(key) {
return key.toString().length % this.size;
}

add(key, value) {
const hash = this.calculateHash(key);
If {
this.values[hash] = {};
}
if {
this.length++;
}
this.values[hash][key] = value;
}

search(key) {
const hash = this.calculateHash(key);
if && {
return this.values[hash][key];
} else {
return null;
}
}
}

//create object of type hash table
const ht = new HashTable();
//add data to the hash table ht
ht.add("Canada", "300");
ht.add("Germany", "100");
ht.add("Italy", "50");

//search

moon-bbtq
Автор

Anyone please explain total += key.characterCodeAt(i)

Adarshabinash
Автор

Great explanation. But man why you hate semicolons so much :D

stoyanradichev