Learn Hash Tables in 13 minutes

  Рет қаралды 357,001

Bro Code

Bro Code

Күн бұрын

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

Пікірлер: 175
@BroCodez
@BroCodez 2 жыл бұрын
import java.util.*; public class Main{ public static void main(String args[]) { // Hashtable = A data structure that stores unique keys to values ex. // 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 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()) { System.out.println(key.hashCode() % 10 + "\t" + key + "\t" + table.get(key)); } } }
@ihateorangecat
@ihateorangecat 2 жыл бұрын
more python tutorials please bro🙏
@ashutoshsoni9723
@ashutoshsoni9723 2 жыл бұрын
Bro can you please make a video on Library Management System in JAVA. It's my request please!
@masternobody1896
@masternobody1896 2 жыл бұрын
nice
@joyceasante8292
@joyceasante8292 Жыл бұрын
import java.util.*; public class Main { public static void main(String[] args) { Hashtabletable = new Hashtable(10); table.put(254,"Irene"); table.put(802,"Derrek"); table.put(671,"Alonso"); table.put(545,"Veronica"); //System.out.println(table.get(545)); //table.remove(671); for(Integer key : table.keySet()){ //System.out.println(key + "\t" + table.get(key)); System.out.println(key.hashCode() % 10 + "\t" + key + "\t" + table.get(key)); } } } _____________________________________________ import java.util.*; public class Main { public static void main(String[] args) { Hashtabletable = new Hashtable(10); table.put("254","Irene"); table.put("802","Derrek"); table.put("671","Alonso"); table.put("545","Veronica"); //table.remove(671); for(String key : table.keySet()){ //System.out.println(key.hashCode() + "\t" + key + "\t" + table.get(key)); //System.out.println(key.hashCode() % 10 + "\t" + key + "\t" + table.get(key)); //System.out.println(key.hashCode() % 11 + "\t" + key + "\t" + table.get(key)); System.out.println(key.hashCode() % 21 + "\t" + key + "\t" + table.get(key)); } } }
@pavanimaddala8060
@pavanimaddala8060 Жыл бұрын
Can you explain how to create hash table in mysql
@Aussiesnrg
@Aussiesnrg 7 ай бұрын
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.
@marius.y6360
@marius.y6360 2 жыл бұрын
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😎
@blu5175
@blu5175 2 жыл бұрын
whats a graphic library im new sorry
@intifadayuri
@intifadayuri 2 жыл бұрын
@@blu5175 libraries in java are a series of already build methods that you can use. For example, whenever you want to write something in the java console you need to import the java.util.Scanner library. My guess is that this guy is talking about a library to build a 3d engine with java
@blu5175
@blu5175 2 жыл бұрын
@@intifadayuri Yea I learnt this by now it's been 11 months! Haha but still thank you very much?
@AMZ_official
@AMZ_official Жыл бұрын
@@blu5175 It's been 11 months again! did you complete it? What else have you achieved in your career? Asking for just motivation
@RonnieBanerjee007
@RonnieBanerjee007 5 ай бұрын
​@@intifadayuri well, you tried to help, that's what counts ❤
@dmitriivlasov3728
@dmitriivlasov3728 2 жыл бұрын
Bro, We just started going through Hash Tables in our CompSci class and now you release a video. Thank you!
@WorkSmarter__
@WorkSmarter__ 2 жыл бұрын
Level of teaching of Bro is just on another level👍
@thomashansknecht1898
@thomashansknecht1898 Жыл бұрын
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.
@randomrun1
@randomrun1 10 ай бұрын
That's interesting, I'm about to start my BSCS and I'm pregaming with the popular Java MOOC. It has an explanation of how to use hash tables in the 8th week and how to make them from scratch in the 12th week. Glad I got the info there if it's not going to be in my curriculum.
@clashclans9783
@clashclans9783 9 ай бұрын
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!!!!
@VERY_TALL_MAN
@VERY_TALL_MAN 2 жыл бұрын
Wow, this is a really good introduction to hash tables!
@BroCodez
@BroCodez 2 жыл бұрын
thanks Grayson!
@deepakr1945
@deepakr1945 2 жыл бұрын
@@BroCodez it bad
@elielvieira3041
@elielvieira3041 Жыл бұрын
@@deepakr1945 nah
@windigo77
@windigo77 10 ай бұрын
It's too bad it violates the ADA with its use of camelCase for method names, and is therefore an illegal language to use in the workplace
@crossfadez5521
@crossfadez5521 Жыл бұрын
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.
@PratikThisSide
@PratikThisSide 2 жыл бұрын
Simply, subtly & nearly explained Bro Sir 👌🏼 #KeelItUp ✌🏼 #LoveFromINDIA🇮🇳
@dbvs007
@dbvs007 2 жыл бұрын
Thank you, I have been having questions on HashTable and wanted to understand hashCode, excellent explanation, keep doing more videos.
@hwstar9416
@hwstar9416 11 ай бұрын
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.
@mikoalt
@mikoalt 10 ай бұрын
Can you explain the bitwise with table size if the power is 2?
@ThomasEdits
@ThomasEdits 10 ай бұрын
I just found out about hashtables so I would appreciate some input: If you are using a hashtable for storing dynamic data, how would you know what hash function always guarantees no collisions?
@hwstar9416
@hwstar9416 9 ай бұрын
@@ThomasEdits your data is never truly random. You can always make your hash function avoid collisions (not always completely) by analyzing your data and coming up with a good hash
@oogshow2809
@oogshow2809 2 жыл бұрын
It’s beautiful lecture I like this hash , I’m always favourite your lecture bro due to your best explanation , keep going bro
@ruleoflawedutainment
@ruleoflawedutainment 2 жыл бұрын
I studied this last term but didn't understand what I do now. Thank you.
@patriciale6647
@patriciale6647 5 ай бұрын
I didn't pay attention during lecture and I have a quiz tomorrow, so this is a lifesaver!
@umut_satir
@umut_satir 4 ай бұрын
i didn't understand the other videos but you clearly explained how it works, thanks for the content
@aryankumar313
@aryankumar313 Жыл бұрын
Brooo!!!!....you just explain so good!....got it just by watching it once!
@mjjrr1331
@mjjrr1331 4 ай бұрын
Simple and understandable. Thank you so much for this tutorial!
@daviduntalan
@daviduntalan Жыл бұрын
thank you for this tutorial, now i can finally understand the HashTable.
@stephanieezat-panah7750
@stephanieezat-panah7750 2 жыл бұрын
As always, an excellent presentation. thank you
@joeyfarrell4399
@joeyfarrell4399 6 ай бұрын
I love this channel so, so much
@robdimmitt3204
@robdimmitt3204 Жыл бұрын
Unbelievably good video
@collectick
@collectick 3 ай бұрын
Better explanation than my computer science teacher, and my native language isn't event english! :)
@mistersir3185
@mistersir3185 Жыл бұрын
good surface level info
@P0K0
@P0K0 Жыл бұрын
The best video I've seen today ❤
@stillpickinganame5350
@stillpickinganame5350 3 ай бұрын
Very good, thank you!
@eugenezuev7349
@eugenezuev7349 27 күн бұрын
sweeet
@maggiemauno
@maggiemauno 6 ай бұрын
I love youuu🥺🥺 Respectfully BUT sincerely Many thanks!
@ldpenrose
@ldpenrose 2 жыл бұрын
The BRO is BACK!
@alexh3143
@alexh3143 3 ай бұрын
the only video I found that has explained hash tables clearly
@abdalwahedhajomar3898
@abdalwahedhajomar3898 Жыл бұрын
This video is amazingly helpful
@TheFlexath
@TheFlexath 7 ай бұрын
thank you sir , best explanation.
@Mohamed-uf5jh
@Mohamed-uf5jh Жыл бұрын
Good explanation . Liked it a lot !
@tavwalt1973
@tavwalt1973 Жыл бұрын
Wow thank you so much, this was super clear!!!!
@acatisfinetoo3018
@acatisfinetoo3018 9 ай бұрын
Hash table is my favoriate data structure😉
@khushalsinghsaini805
@khushalsinghsaini805 Жыл бұрын
how we can deal with HashTable of Classes? Like in place of int and string key it is some sort of class. Like Hashtable;
@skillR-243
@skillR-243 2 жыл бұрын
Thanks for this videos Bro!
@ChristianRodriguez-tm3jg
@ChristianRodriguez-tm3jg Жыл бұрын
thanks bro... greetings from Ecuador
@Code_JAVA268
@Code_JAVA268 5 ай бұрын
tooo cool man
@wrizu
@wrizu 2 ай бұрын
how do you access a vlue from a bucket it only shows the head (first) value.
@mohitjain957
@mohitjain957 2 жыл бұрын
bro you are insane Thanks sir I really appreciate
@akmalbukhariev7932
@akmalbukhariev7932 6 ай бұрын
Thank you so much sir.
@ethio15code
@ethio15code 7 ай бұрын
Nice explanation 👍
@punzalanchristine2442
@punzalanchristine2442 8 ай бұрын
what do you call when u give that type of solution in collision, is it open hashing or not?
@mugosimon717
@mugosimon717 Жыл бұрын
you are the best
@hypnos9336
@hypnos9336 5 ай бұрын
helpful, thank you
@callmesuraj4257
@callmesuraj4257 2 жыл бұрын
Bro 🤩 Tq 4 your Quality coding Video. & Now i am busy with your python 🐍course. Tnx again ☺️. Bro ✌️🎈✌️
@ztipster
@ztipster 5 ай бұрын
Does google uses hash tables to display instant results ?
@flammabletfm3405
@flammabletfm3405 2 жыл бұрын
Wow! Nice.
@facuz4170
@facuz4170 Жыл бұрын
Nice video!
@lucacodastefano2409
@lucacodastefano2409 2 жыл бұрын
Very nice lesson, like every other!
@hazmi96
@hazmi96 2 жыл бұрын
Thanks! love your videos!
@danielhowe3393
@danielhowe3393 2 жыл бұрын
Could you go over the A star algorithm next pls
@kosolomon123
@kosolomon123 2 жыл бұрын
good quality content!
@coder4937
@coder4937 2 жыл бұрын
Good work👍👍👍👍
@katendetimothy6542
@katendetimothy6542 2 жыл бұрын
Bro thx for the free videos. How can I apply this topic in real life maybe in GUI?
@justinbanza4079
@justinbanza4079 2 жыл бұрын
Thank you for this video
@DINESH-ji7tm
@DINESH-ji7tm 2 жыл бұрын
Sir , please provide use app development course , It's a very helpful .
@hermansiisengbae
@hermansiisengbae 2 жыл бұрын
Wow 👍👍
@bluekrazykris
@bluekrazykris 2 жыл бұрын
What's the difference between Hash tables and hash maps?
@migelangelcarrillo1710
@migelangelcarrillo1710 Жыл бұрын
@@dispatch-indirect9206 he/she asked for the difference, not your opinion on the subject
@trevorphilipsindustries1046
@trevorphilipsindustries1046 Жыл бұрын
I'm wondering if these hashcodes been written incorrectly here 3:49 Because the hashcode of String "100" would be 47155, not 48625. and here is why: Initialize hash to 0: hash = 0. Multiply hash by 31 and add the numeric value of the first character '1': hash = (0 * 31) + 49 = 49. Multiply hash by 31 and add the numeric value of the second character '0': hash = (49 * 31) + 48 = 1517. Multiply hash by 31 and add the numeric value of the third character '0': hash = (1517 * 31) + 48 = 47155. so, am I right, these numbers in the example's hashcode are just random numbers and have nothing to do with the righ hashcodes?
@SaiMoen
@SaiMoen Жыл бұрын
10:15
@jeonjungkook-vu4fg
@jeonjungkook-vu4fg Жыл бұрын
i HAVE MY FINAL EXAM IN TWO DAYS.... I HOPE I PASSS
@hasinulhudaenu8098
@hasinulhudaenu8098 4 ай бұрын
Did you pass??
@mostafayounes9490
@mostafayounes9490 2 ай бұрын
Thank you ❤
@nageshmh
@nageshmh 3 ай бұрын
Awesome
@MrLoser-ks2xn
@MrLoser-ks2xn Жыл бұрын
Thanks!
@emiralpkilic5669
@emiralpkilic5669 11 ай бұрын
Eyyo Brooooo you are a legend!!!
@KiranNaragam
@KiranNaragam 3 ай бұрын
GOAT Video of HashTable
@SlashKilll
@SlashKilll Жыл бұрын
THANK YOU YOU SAVED ME
@touzaikokon
@touzaikokon Жыл бұрын
thanks bro
@Heyleang
@Heyleang 3 ай бұрын
Thank man
@TylerBriggs-m2y
@TylerBriggs-m2y 10 ай бұрын
Well done, TY!
@thedojoclub
@thedojoclub Жыл бұрын
thank god for Bro!
@victorrezende6002
@victorrezende6002 11 ай бұрын
Nice class
@gerxisander5294
@gerxisander5294 2 жыл бұрын
very nice tutorial. BIG LIKE
@jimmy2055
@jimmy2055 11 ай бұрын
wish u did this in c++
@visitor404
@visitor404 Жыл бұрын
Bro 🤜🤛
@ruthvikas
@ruthvikas 2 жыл бұрын
@Bro code, it would be great if you teach android development with kotlin also...
@hyvaahyvaa9578
@hyvaahyvaa9578 Жыл бұрын
hi is it possible to implement the hash table using an array?
@owlexb1124
@owlexb1124 2 жыл бұрын
Thank you!
@vishnuskandata2355
@vishnuskandata2355 Жыл бұрын
isnt it just jumbling the order? how is that more efficient? I'm confused.
@getyournekoshere9824
@getyournekoshere9824 Жыл бұрын
nice vid man thanks
@BioDeus
@BioDeus Жыл бұрын
I was thinking the table size should be a prime to reduce collisions, no? Should have tried 13 first.
@YDV669
@YDV669 7 ай бұрын
Back in Image/3000 days(70s, 80s, 90s, early 2000s), master tables(manual and automatic) were hashed with collisions resolved exactly as in this video. The rule was to create such tables with a capacity of a prime number. If you need a million rows in your table, set the capacity to the next prime number. it wasn't enforced by the database, actually, but later, utilities were created to help in resizing tables and these would actually tell you what your capacity should be based on what you requested.
@schifoso
@schifoso 8 ай бұрын
Make hash table size a prime number.
@heavenlypenguin6613
@heavenlypenguin6613 Жыл бұрын
Thank you Bro!
@user27108
@user27108 2 жыл бұрын
how many programing languages you know?
@firepower01
@firepower01 2 жыл бұрын
Thanks Bro
@DesiredFactsDaily
@DesiredFactsDaily Жыл бұрын
Bruh I am from pandora huge love and want to take you to my planet and our avatar.jr too learn ds to crack FANG companies
@xinfangmin3665
@xinfangmin3665 2 жыл бұрын
Never be so early!
@dennismc8145
@dennismc8145 Жыл бұрын
I love you
@ox6542
@ox6542 Ай бұрын
Functions as a map
@huyngo2u924
@huyngo2u924 2 жыл бұрын
heap sort, please
@juanpunch8473
@juanpunch8473 2 жыл бұрын
data structure is far more easy in java compare to c++ :
@karlostj4683
@karlostj4683 8 ай бұрын
"...divide it by the capacity of our hash table, and find the remainder..." Except that's not what the narrator is actually doing - the narrator is just doing the modulus without doing the division. Why?
@karlostj4683
@karlostj4683 8 ай бұрын
For the entry ("100", "Spongebob") hashing "100" --> 48625. 48625 divided by the capacity --> 4862. 4862 modulo 10 --> 2. But what the narrator did was "100" --> 48625 then 48625 % 10 --> 5.
@oe7356
@oe7356 7 ай бұрын
@@karlostj4683 48625 / 10 = 4862 remainder 5. Modulus directly computes the remainder.
@X_Potato
@X_Potato 5 ай бұрын
I dont understand something here, how does searching actually get faster? if you dont know the key or the index how is it different from not knowing the index in an array?
@XxxxTxTxxxX
@XxxxTxTxxxX 5 ай бұрын
If you don't know the key then you would have to iterate over the hashtable. If you're performing those kind of searches then just don't use a hashtable. A search tree would be a better choice
@kylebelle246
@kylebelle246 4 ай бұрын
You should always know the key. and since the index is just calculated by the key you also inherently know the index. searching only kinda comes into play if there were collisions and in that case you are now searching a much smaller subset opposed to an array where you would be searching, possibly, the entire array.
@kylebelle246
@kylebelle246 4 ай бұрын
in this example he used numbers as keys, but in the real world you'd probably use the name as a key (e.g "spongebob") and then store some sort of object (or any type of data doesn't really matter) as the value. The key isn't supposed to be just any random/arbitrary value, it should have some meaning in your context
@FranklinBegley-f1x
@FranklinBegley-f1x 21 күн бұрын
Lee Karen Robinson Elizabeth Brown Sarah
@apmcd47
@apmcd47 Жыл бұрын
Wait, Gary Seven?
@v.f.38
@v.f.38 2 жыл бұрын
Teach golang.
@immortalbotyt1428
@immortalbotyt1428 2 жыл бұрын
Cmon C# is not bad either u can't ignore a good language what can be used to create android ios apps , with xamarin , can used to develop OP games at unity and so on cmon bro plssssssssssssssssssssss
@junaidrashid7525
@junaidrashid7525 15 күн бұрын
pever
@alpeshamriwala1740
@alpeshamriwala1740 2 жыл бұрын
Thanks bro 😭
Learn Graphs in 5 minutes 🌐
5:17
Bro Code
Рет қаралды 115 М.
Top 7 Data Structures for Interviews Explained SIMPLY
13:02
Codebagel
Рет қаралды 191 М.
Worst flight ever
00:55
Adam W
Рет қаралды 25 МЛН
А ВЫ ЛЮБИТЕ ШКОЛУ?? #shorts
00:20
Паша Осадчий
Рет қаралды 9 МЛН
Cute
00:16
Oyuncak Avı
Рет қаралды 12 МЛН
Learn Merge Sort in 13 minutes 🔪
13:45
Bro Code
Рет қаралды 302 М.
Faster than Rust and C++: the PERFECT hash table
33:52
strager
Рет қаралды 573 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2,1 МЛН
Hash Tables and Hash Functions
13:56
Computer Science
Рет қаралды 1,6 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 546 М.
Set and HashSet in Java - Full Tutorial
20:43
Coding with John
Рет қаралды 219 М.
God-Tier Developer Roadmap
16:42
Fireship
Рет қаралды 7 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 364 М.
Understanding and implementing a Hash Table (in C)
24:54
Jacob Sorber
Рет қаралды 355 М.
you will never ask about pointers again after watching this video
8:03
Worst flight ever
00:55
Adam W
Рет қаралды 25 МЛН