Learn Hash Tables in 13 minutes

  Рет қаралды 306,923

Bro Code

Bro Code

2 жыл бұрын

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

Пікірлер: 161
@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)); } } }
@54peace
@54peace 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 3 ай бұрын
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
@Proletariat-intifada
@Proletariat-intifada Жыл бұрын
@@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 Жыл бұрын
@@Proletariat-intifada Yea I learnt this by now it's been 11 months! Haha but still thank you very much?
@AMZ_official
@AMZ_official 7 ай бұрын
@@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 Ай бұрын
​@@Proletariat-intifada 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!
@mjjrr1331
@mjjrr1331 14 күн бұрын
Simple and understandable. Thank you so much for this tutorial!
@VERY_TALL_MAN
@VERY_TALL_MAN 2 жыл бұрын
Wow, this is a really good introduction to hash tables!
@BroCodez
@BroCodez 2 жыл бұрын
thanks Grayson!
@deepakr1945
@deepakr1945 Жыл бұрын
@@BroCodez it bad
@elielvieira3041
@elielvieira3041 Жыл бұрын
@@deepakr1945 nah
@windigo77
@windigo77 6 ай бұрын
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
@clashclans9783
@clashclans9783 5 ай бұрын
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!!!!
@WorkSmarter__
@WorkSmarter__ 2 жыл бұрын
Level of teaching of Bro is just on another level👍
@crossfadez5521
@crossfadez5521 11 ай бұрын
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.
@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.
@dispatch-indirect9206
@dispatch-indirect9206 11 ай бұрын
_I am surprised my computer science curriculum barely even mentioned hash tables_ From interviewing people, this seems like fairly common practice in CS. But chasing buzzwords is devaluing CS: these fundamentals are what distinguished a four-year degree from a coding bootcamp.
@randomrun1
@randomrun1 6 ай бұрын
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.
@PratikThisSide
@PratikThisSide 2 жыл бұрын
Simply, subtly & nearly explained Bro Sir 👌🏼 #KeelItUp ✌🏼 #LoveFromINDIA🇮🇳
@confused6526
@confused6526 3 ай бұрын
Oh My Goodness... The best video on HashMap data structure. You're the man! 👍
@dbvs007
@dbvs007 Жыл бұрын
Thank you, I have been having questions on HashTable and wanted to understand hashCode, excellent explanation, keep doing more videos.
@gerxisander5294
@gerxisander5294 2 жыл бұрын
very nice tutorial. BIG LIKE
@umut_satir
@umut_satir 3 күн бұрын
i didn't understand the other videos but you clearly explained how it works, thanks for the content
@stephanieezat-panah7750
@stephanieezat-panah7750 2 жыл бұрын
As always, an excellent presentation. thank you
@nischalofchrist
@nischalofchrist Жыл бұрын
Bro, you Rock. Best and simple explanation of Hash tables. Thanks
@patriciale6647
@patriciale6647 Ай бұрын
I didn't pay attention during lecture and I have a quiz tomorrow, so this is a lifesaver!
@abdalwahedhajomar3898
@abdalwahedhajomar3898 11 ай бұрын
This video is amazingly helpful
@ruleoflawedutainment
@ruleoflawedutainment 2 жыл бұрын
I studied this last term but didn't understand what I do now. Thank you.
@daviduntalan
@daviduntalan Жыл бұрын
thank you for this tutorial, now i can finally understand the HashTable.
@randomrun1
@randomrun1 6 ай бұрын
This is a great video, thank you. It's much clearer than my course material.
@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
@aryankumar313
@aryankumar313 9 ай бұрын
Brooo!!!!....you just explain so good!....got it just by watching it once!
@hwstar9416
@hwstar9416 7 ай бұрын
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 6 ай бұрын
Can you explain the bitwise with table size if the power is 2?
@ThomasEdits
@ThomasEdits 5 ай бұрын
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 5 ай бұрын
@@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
@lucacodastefano2409
@lucacodastefano2409 2 жыл бұрын
Very nice lesson, like every other!
@hazmi96
@hazmi96 2 жыл бұрын
Thanks! love your videos!
@robdimmitt3204
@robdimmitt3204 Жыл бұрын
Unbelievably good video
@rmsoft
@rmsoft 3 ай бұрын
Really good, no babbling, just information.
@mistersir3185
@mistersir3185 Жыл бұрын
good surface level info
@TheFlexath
@TheFlexath 3 ай бұрын
thank you sir , best explanation.
@recipeFor
@recipeFor Жыл бұрын
Thanks a lot for providing a valuable video.
@tavwalt1973
@tavwalt1973 10 ай бұрын
Wow thank you so much, this was super clear!!!!
@joeyfarrell4399
@joeyfarrell4399 2 ай бұрын
I love this channel so, so much
@ethio15code
@ethio15code 3 ай бұрын
Nice explanation 👍
@Mohamed-uf5jh
@Mohamed-uf5jh Жыл бұрын
Good explanation . Liked it a lot !
@victors8718
@victors8718 4 ай бұрын
Bro is an absolute legend
@acatisfinetoo3018
@acatisfinetoo3018 5 ай бұрын
Hash table is my favoriate data structure😉
@zeeg1529
@zeeg1529 2 ай бұрын
top quality content. great job, Bro!
@mohitjain957
@mohitjain957 Жыл бұрын
bro you are insane Thanks sir I really appreciate
@P0K0
@P0K0 11 ай бұрын
The best video I've seen today ❤
@joseoterol
@joseoterol 10 ай бұрын
I love that man. Thanks mate
@gamermachine4048
@gamermachine4048 2 жыл бұрын
Nice, can you make a video on suppliers and consumers next?
@akmalbukhariev7932
@akmalbukhariev7932 Ай бұрын
Thank you so much sir.
@ldpenrose
@ldpenrose 2 жыл бұрын
The BRO is BACK!
@ztipster
@ztipster Ай бұрын
Does google uses hash tables to display instant results ?
@kosolomon123
@kosolomon123 2 жыл бұрын
good quality content!
@skillraiderv5289
@skillraiderv5289 2 жыл бұрын
Thanks for this videos Bro!
@jordimorenosanchez584
@jordimorenosanchez584 9 ай бұрын
I thought I understood what a hash table was till I saw this video 🙏
@ChristianRodriguez-tm3jg
@ChristianRodriguez-tm3jg Жыл бұрын
thanks bro... greetings from Ecuador
@justinbanza4079
@justinbanza4079 2 жыл бұрын
Thank you for this video
@hypnos9336
@hypnos9336 Ай бұрын
helpful, thank you
@user-ss2rt9xk4g
@user-ss2rt9xk4g 6 ай бұрын
Well done, TY!
@patahgaming
@patahgaming 6 ай бұрын
I learn how to use hash table without tutorial now :)
@margretmauno1285
@margretmauno1285 2 ай бұрын
I love youuu🥺🥺 Respectfully BUT sincerely Many thanks!
@punzalanchristine2442
@punzalanchristine2442 4 ай бұрын
what do you call when u give that type of solution in collision, is it open hashing or not?
@ukaszkiepas57
@ukaszkiepas57 3 ай бұрын
thank you bro. Student from Poland :>
@danielhowe3393
@danielhowe3393 2 жыл бұрын
Could you go over the A star algorithm next pls
@DINESH-ji7tm
@DINESH-ji7tm 2 жыл бұрын
Sir , please provide use app development course , It's a very helpful .
@Piseth_01
@Piseth_01 2 жыл бұрын
In cars stuff we have Chrisfix in computer stuff we have my bro right here.
@SlashKilll
@SlashKilll Жыл бұрын
THANK YOU YOU SAVED ME
@mugosimon717
@mugosimon717 8 ай бұрын
you are the best
@emiralpkilic5669
@emiralpkilic5669 7 ай бұрын
Eyyo Brooooo you are a legend!!!
@hyvaahyvaa9578
@hyvaahyvaa9578 Жыл бұрын
hi is it possible to implement the hash table using an array?
@Code_JAVA268
@Code_JAVA268 Ай бұрын
tooo cool man
@katendetimothy6542
@katendetimothy6542 2 жыл бұрын
Bro thx for the free videos. How can I apply this topic in real life maybe in GUI?
@ruthvikas
@ruthvikas 2 жыл бұрын
@Bro code, it would be great if you teach android development with kotlin also...
@xxmsdxx
@xxmsdxx 2 жыл бұрын
Keep going ❤
@flammabletfm3405
@flammabletfm3405 2 жыл бұрын
Wow! Nice.
@heavenlypenguin6613
@heavenlypenguin6613 Жыл бұрын
Thank you Bro!
@facuz4170
@facuz4170 11 ай бұрын
Nice video!
@owlexb1124
@owlexb1124 2 жыл бұрын
Thank you!
@StephanHaloftis
@StephanHaloftis Жыл бұрын
Is it possible to design the table to have a dynamic capacity that can be adjusted if there are collisions?
@kylebelle246
@kylebelle246 4 күн бұрын
i could see this taking more work and end up being slower than just appending to the linked list, since you the existing element now also need to be moved since their table index may no longer be the same give the remainder will likely be different. i would say just make sure the hashtable is sized appropriately and at that point you've done the best you could
@coder4937
@coder4937 2 жыл бұрын
Good work👍👍👍👍
@alanfrost2973
@alanfrost2973 2 жыл бұрын
Another day Thank you so much if you ever have membership for no reason ill try to join to money you deserve it
@hermansiisengbae
@hermansiisengbae 2 жыл бұрын
Wow 👍👍
@elias6406
@elias6406 Жыл бұрын
What’s the difference between hashtable and hashmaps?
@HarryInShape
@HarryInShape 16 күн бұрын
I love you Bro
@alimasterchess778
@alimasterchess778 2 жыл бұрын
Bro can you please do assembler tutorial videos?
@khushalsinghsaini805
@khushalsinghsaini805 11 ай бұрын
how we can deal with HashTable of Classes? Like in place of int and string key it is some sort of class. Like Hashtable;
@getyournekoshere9824
@getyournekoshere9824 Жыл бұрын
nice vid man thanks
@victorrezende6002
@victorrezende6002 7 ай бұрын
Nice class
@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
@SnackPacks10
@SnackPacks10 11 ай бұрын
Can you find the values in your hash table from its address?
@issac17
@issac17 2 жыл бұрын
Thanks man I really appreciate ❤️
@BroCodez
@BroCodez 2 жыл бұрын
anytime! Thanks for commenting
@issac17
@issac17 2 жыл бұрын
Your videos are really helpful...you deserved it❤️
@visitor404
@visitor404 11 ай бұрын
Bro 🤜🤛
@adheesh2secondsago630
@adheesh2secondsago630 2 жыл бұрын
Nice👍
@user27108
@user27108 2 жыл бұрын
how many programing languages you know?
@MrLoser-ks2xn
@MrLoser-ks2xn 11 ай бұрын
Thanks!
@ngndnd
@ngndnd Жыл бұрын
so its the exact same as a hashmap?
@filipedlund7038
@filipedlund7038 2 жыл бұрын
What to do when the ids of students are the same? Thanks
@koctarac
@koctarac 2 жыл бұрын
Do you have a patreon or paypal for us to donate?
@gksw_g1437
@gksw_g1437 2 жыл бұрын
thanks!
@touzaikokon
@touzaikokon Жыл бұрын
thanks bro
@firepower01
@firepower01 Жыл бұрын
Thanks Bro
@thedojoclub
@thedojoclub Жыл бұрын
thank god for Bro!
@alpeshamriwala1740
@alpeshamriwala1740 2 жыл бұрын
Thanks bro 😭
@joseluizdurigon8893
@joseluizdurigon8893 Жыл бұрын
Ok, but the bucket we're talking about is a memory address? I mean, if we have a collision, we must create a linked list. Fine with that I get it, but that linked list will be stored in the same memory address? I don't think I'm rationalizing right. The linked list will be stored like a vector and the data that has a collision will have a pointer to that new node right? I'm sorry if I sound a little bit confusing but that's what I've figured out
@kylebelle246
@kylebelle246 4 күн бұрын
What if it was always a linked list? even if there are no collisions and the linked list only contains one node. I think that'd make more sense
@jimmy2055
@jimmy2055 7 ай бұрын
wish u did this in c++
@bluekrazykris
@bluekrazykris 2 жыл бұрын
What's the difference between Hash tables and hash maps?
@dispatch-indirect9206
@dispatch-indirect9206 11 ай бұрын
The short answer is you shouldn't use Hashtable and this video shouldn't recommend Hashtable, though this confusion is partly on Oracle. The original collections, especially Hashtable and Vector, were all made to be thread safe. This was only useful in specific cases and the method of making them thread safe was not performant. Per the API docs for Hashtable: _As of the Java 2 platform v1.2, this class was retrofitted to implement the Map interface, making it a member of the Java Collections Framework. Unlike the new collection implementations, Hashtable is synchronized. If a thread-safe implementation is not needed, it is recommended to use HashMap in place of Hashtable. If a thread-safe highly-concurrent implementation is desired, then it is recommended to use ConcurrentHashMap in place of Hashtable._
@migelangelcarrillo1710
@migelangelcarrillo1710 11 ай бұрын
@@dispatch-indirect9206 he/she asked for the difference, not your opinion on the subject
Learn Graphs in 5 minutes 🌐
5:17
Bro Code
Рет қаралды 90 М.
Hash Tables and Hash Functions
13:56
Computer Science
Рет қаралды 1,5 МЛН
Cute Barbie gadgets 🩷💛
01:00
TheSoul Music Family
Рет қаралды 65 МЛН
Normal vs Smokers !! 😱😱😱
00:12
Tibo InShape
Рет қаралды 113 МЛН
La final estuvo difícil
00:34
Juan De Dios Pantoja
Рет қаралды 26 МЛН
Faster than Rust and C++: the PERFECT hash table
33:52
strager
Рет қаралды 506 М.
Understanding and implementing a Hash Table (in C)
24:54
Jacob Sorber
Рет қаралды 337 М.
you will never ask about pointers again after watching this video
8:03
Low Level Learning
Рет қаралды 2 МЛН
Learn Quick Sort in 13 minutes ⚡
13:49
Bro Code
Рет қаралды 276 М.
Hashing Algorithms and Security - Computerphile
8:12
Computerphile
Рет қаралды 1,4 МЛН
How to Implement a Hash Table in JavaScript
25:39
Ben Awad
Рет қаралды 102 М.
Java HashMap 🗺️
13:05
Bro Code
Рет қаралды 73 М.
What is a HashTable Data Structure - Introduction to Hash Tables , Part 0
7:37
Эффект Карбонаро и бумажный телефон
1:01
История одного вокалиста
Рет қаралды 2,5 МЛН
Добавления ключа в домофон ДомРу
0:18
Wow AirPods
0:17
ARGEN
Рет қаралды 1,2 МЛН
3D printed Nintendo Switch Game Carousel
0:14
Bambu Lab
Рет қаралды 4,5 МЛН
Трагичная История Девушки 😱🔥
0:58
Смотри Под Чаёк
Рет қаралды 364 М.