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)); } } }
@ihateorangecat3 жыл бұрын
more python tutorials please bro🙏
@ashutoshsoni97233 жыл бұрын
Bro can you please make a video on Library Management System in JAVA. It's my request please!
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.y63603 жыл бұрын
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😎
@blu51753 жыл бұрын
whats a graphic library im new sorry
@intifadayuri2 жыл бұрын
@@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
@blu51752 жыл бұрын
@@intifadayuri Yea I learnt this by now it's been 11 months! Haha but still thank you very much?
@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
@RonnieBanerjee0077 ай бұрын
@@intifadayuri well, you tried to help, that's what counts ❤
@WorkSmarter__3 жыл бұрын
Level of teaching of Bro is just on another level👍
@dmitriivlasov37283 жыл бұрын
Bro, We just started going through Hash Tables in our CompSci class and now you release a video. Thank you!
@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 Жыл бұрын
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.
@clashclans978311 ай бұрын
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_MAN3 жыл бұрын
Wow, this is a really good introduction to hash tables!
@BroCodez3 жыл бұрын
thanks Grayson!
@deepakr19452 жыл бұрын
@@BroCodez it bad
@elielvieira3041 Жыл бұрын
@@deepakr1945 nah
@windigo77 Жыл бұрын
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 Жыл бұрын
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.
@hwstar9416 Жыл бұрын
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 Жыл бұрын
Can you explain the bitwise with table size if the power is 2?
@ThomasEdits Жыл бұрын
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?
@hwstar941611 ай бұрын
@@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
@confused65269 ай бұрын
Oh My Goodness... The best video on HashMap data structure. You're the man! 👍
@AlexStampfl-f4p18 күн бұрын
Your videos are awesome, far better and easier to understand than my useless, confusing lectures, thanks!
@dbvs0072 жыл бұрын
Thank you, I have been having questions on HashTable and wanted to understand hashCode, excellent explanation, keep doing more videos.
I studied this last term but didn't understand what I do now. Thank you.
@oogshow28093 жыл бұрын
It’s beautiful lecture I like this hash , I’m always favourite your lecture bro due to your best explanation , keep going bro
@patriciale66477 ай бұрын
I didn't pay attention during lecture and I have a quiz tomorrow, so this is a lifesaver!
@joeyfarrell43998 ай бұрын
I love this channel so, so much
@stephanieezat-panah77502 жыл бұрын
As always, an excellent presentation. thank you
@nischalofchrist2 жыл бұрын
Bro, you Rock. Best and simple explanation of Hash tables. Thanks
@coder49373 жыл бұрын
Good work👍👍👍👍
@DTALKS0125 күн бұрын
bro save my lots of time to learn this all by reading some article or docs , amazing video thank you sir
@aryankumar313 Жыл бұрын
Brooo!!!!....you just explain so good!....got it just by watching it once!
@cheshirecat11127 күн бұрын
Watched 3 vids on this. Yours was best.
@daviduntalan Жыл бұрын
thank you for this tutorial, now i can finally understand the HashTable.
@rmsoft9 ай бұрын
Really good, no babbling, just information.
@TheFlexath9 ай бұрын
thank you sir , best explanation.
@umut_satir6 ай бұрын
i didn't understand the other videos but you clearly explained how it works, thanks for the content
@mugosimon717 Жыл бұрын
you are the best
@kosolomon1232 жыл бұрын
good quality content!
@victorrezende6002 Жыл бұрын
Nice class
@HarryInShape6 ай бұрын
I love you Bro
@randomrun1 Жыл бұрын
This is a great video, thank you. It's much clearer than my course material.
@abdalwahedhajomar3898 Жыл бұрын
This video is amazingly helpful
@hazmi963 жыл бұрын
Thanks! love your videos!
@collectick5 ай бұрын
Better explanation than my computer science teacher, and my native language isn't event english! :)
@robertedwards44013 ай бұрын
Great video, thank you
@nageshmh5 ай бұрын
Awesome
@xxmsdxx3 жыл бұрын
Keep going ❤
@justinbanza40792 жыл бұрын
Thank you for this video
@flammabletfm34053 жыл бұрын
Wow! Nice.
@adheesh2secondsago6303 жыл бұрын
Nice👍
@P0K0 Жыл бұрын
The best video I've seen today ❤
@hermansiisengbae3 жыл бұрын
Wow 👍👍
@eugenezuev73492 ай бұрын
sweeet
@zeeg15298 ай бұрын
top quality content. great job, Bro!
@ferencbesenyei67134 ай бұрын
Excellent!
@jordimorenosanchez584 Жыл бұрын
I thought I understood what a hash table was till I saw this video 🙏
@facuz4170 Жыл бұрын
Nice video!
@recipeFor2 жыл бұрын
Thanks a lot for providing a valuable video.
@Mohamed-uf5jh Жыл бұрын
Good explanation . Liked it a lot !
@TheCuriousLifeOfCode3 жыл бұрын
The BRO is BACK!
@victors871810 ай бұрын
Bro is an absolute legend
@visitor404 Жыл бұрын
Bro 🤜🤛
@lucacodastefano24092 жыл бұрын
Very nice lesson, like every other!
@emiralpkilic5669 Жыл бұрын
Eyyo Brooooo you are a legend!!!
@tavwalt1973 Жыл бұрын
Wow thank you so much, this was super clear!!!!
@mohitjain9572 жыл бұрын
bro you are insane Thanks sir I really appreciate
@mjjrr13316 ай бұрын
Simple and understandable. Thank you so much for this tutorial!
@ukaszkiepas579 ай бұрын
thank you bro. Student from Poland :>
@stillpickinganame53505 ай бұрын
Very good, thank you!
@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
@kylebelle2466 ай бұрын
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
@akmalbukhariev79328 ай бұрын
Thank you so much sir.
@hypnos93367 ай бұрын
helpful, thank you
@Code_JAVA2687 ай бұрын
tooo cool man
@patahgaming Жыл бұрын
I learn how to use hash table without tutorial now :)
@Seth_Sun3 жыл бұрын
In cars stuff we have Chrisfix in computer stuff we have my bro right here.
@ChristianRodriguez-tm3jg Жыл бұрын
thanks bro... greetings from Ecuador
@maggiemauno8 ай бұрын
I love youuu🥺🥺 Respectfully BUT sincerely Many thanks!
@WizardMoDz2 ай бұрын
🙌
@joseoterol Жыл бұрын
I love that man. Thanks mate
@hibasalman8462Ай бұрын
Thanks
@gerxisander52943 жыл бұрын
very nice tutorial. BIG LIKE
@SlashKilll Жыл бұрын
THANK YOU YOU SAVED ME
@skillR-2433 жыл бұрын
Thanks for this videos Bro!
@gamermachine40483 жыл бұрын
Nice, can you make a video on suppliers and consumers next?
@TylerBriggs-m2y Жыл бұрын
Well done, TY!
@issac173 жыл бұрын
Thanks man I really appreciate ❤️
@BroCodez3 жыл бұрын
anytime! Thanks for commenting
@issac173 жыл бұрын
Your videos are really helpful...you deserved it❤️
@touzaikokon Жыл бұрын
thanks bro
@mostafayounes94904 ай бұрын
Thank you ❤
@danielhowe33933 жыл бұрын
Could you go over the A star algorithm next pls
@firepower012 жыл бұрын
Thanks Bro
@DINESH-ji7tm3 жыл бұрын
Sir , please provide use app development course , It's a very helpful .
@KiranNaragam5 ай бұрын
GOAT Video of HashTable
@gksw_g14373 жыл бұрын
thanks!
@owlexb11243 жыл бұрын
Thank you!
@StephanHaloftis Жыл бұрын
Is it possible to design the table to have a dynamic capacity that can be adjusted if there are collisions?
@kylebelle2466 ай бұрын
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
@KaptainLuis5 ай бұрын
thank you soooo much!!!
@callmesuraj42573 жыл бұрын
Bro 🤩 Tq 4 your Quality coding Video. & Now i am busy with your python 🐍course. Tnx again ☺️. Bro ✌️🎈✌️
@getyournekoshere9824 Жыл бұрын
nice vid man thanks
@punzalanchristine244210 ай бұрын
what do you call when u give that type of solution in collision, is it open hashing or not?
@alexh31435 ай бұрын
the only video I found that has explained hash tables clearly
@katendetimothy65423 жыл бұрын
Bro thx for the free videos. How can I apply this topic in real life maybe in GUI?
@ztipster7 ай бұрын
Does google uses hash tables to display instant results ?