Learn Hash Tables in 13 minutes #️⃣

preview_player
Показать описание
Hash Table tutorial example explained

#Hash #Table #Hashtable

// Hashtable = A data structure that stores unique keys to values
Each key/value pair is known as an Entry
FAST insertion, look up, deletion of key/value pairs
Not ideal for small data sets, great with large data sets
Рекомендации по теме
Комментарии
Автор

import java.util.*;

public class Main{

public static void main(String args[]) {

// Hashtable = A data structure that stores unique keys to values ex.<Integer, String>
// Each key/value pair is known as an Entry
// FAST insertion, look up, deletion of key/value pairs
// Not ideal for small data sets, great with large data sets

// hashing = Takes a key and computes an integer (formula will vary based on key & data type)
// In a Hashtable, we use the hash % capacity to calculate an index number

// key.hashCode() % capacity = index

// bucket = an indexed storage location for one or more Entries
// can store multiple Entries in case of a collision (linked similarly a LinkedList)

// collision = hash function generates the same index for more than one key
// less collisions = more efficiency

// Runtime complexity: Best Case O(1)
// Worst Case O(n)

Hashtable<Integer, String> table = new Hashtable<>(10);

table.put(100, "Spongebob");
table.put(123, "Patrick");
table.put(321, "Sandy");
table.put(555, "Squidward");
table.put(777, "Gary");

for(Integer key : table.keySet()) {
% 10 + "\t" + key + "\t" + table.get(key));
}
}
}

BroCodez
Автор

Was a programmer on a statewide court system back in the late 80's that needed a surname search to return a full page of results in less than a second. We used hashing tables and progressive searches to keep the speed amazingly fast. I think we had it down to about 0.2 of a second.
They are fantastic with really large collections of data that needs searching.

Aussiesnrg
Автор

Hey Bro, I just wanna thank you for teaching me all this stuff. 7 months ago I was almost nowhere not even knowing how to write a main method in Java but now I'm programming my own graphics library. You're truly a legend😎

marius.y
Автор

Level of teaching of Bro is just on another level👍

WorkSmarter__
Автор

Bro, We just started going through Hash Tables in our CompSci class and now you release a video. Thank you!

dmitriivlasov
Автор

I am surprised my computer science curriculum barely even mentioned hash tables. They have been such a game changer to me at work as a software engineer. Way faster and easier than using an array and nested loops.

thomashansknecht
Автор

that actually makes so much sense!! was looking at the profssors notes and watching his lectures and not understanding it one single bit!!!! long live the BRO!!!!

clashclans
Автор

Wow, this is a really good introduction to hash tables!

VERY_TALL_MAN
Автор

This was a very insightful video, thanks a lot. Although I really wished you also went over how to treat a bucket as a linked list and iterate through it to find the key you're looking for.

crossfadez
Автор

Things to note:

If you have collisions the best course of action is to change your hash function. In your example, a good hash function would be taking the ascii code of the rightmost number and subtracting 48, that way you'd have 0 collisions and don't need to do % anymore.

Another thing, if your table size is a power of 2 you don't have to do % anymore, you can instead do bitwise and with table size.

hwstar
Автор

Oh My Goodness... The best video on HashMap data structure. You're the man! 👍

confused
Автор

Your videos are awesome, far better and easier to understand than my useless, confusing lectures, thanks!

AlexStampfl-fp
Автор

Thank you, I have been having questions on HashTable and wanted to understand hashCode, excellent explanation, keep doing more videos.

dbvs
Автор

Simply, subtly & nearly explained Bro Sir 👌🏼
#KeelItUp ✌🏼 #LoveFromINDIA🇮🇳

PratikThisSide
Автор

Hash table is my favoriate data structure😉

acatisfinetoo
Автор

It’s beautiful lecture I like this hash, I’m always favourite your lecture bro due to your best explanation, keep going bro

oogshow
Автор

I studied this last term but didn't understand what I do now. Thank you.

ruleoflawedutainment
Автор

I didn't pay attention during lecture and I have a quiz tomorrow, so this is a lifesaver!

patriciale
Автор

As always, an excellent presentation. thank you

stephanieezat-panah
Автор

Bro, you Rock. Best and simple explanation of Hash tables. Thanks

nischalofchrist