Simple Explanation of HashMap, HashSet, ArrayLists and Big O: O(n), O(1)

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • An explanation of algorithm growth rates (Big O) and different collection types: HashMap, HashTable, and ArrayList. In this video, I show how ArrayList fetch and insert at the beginning operations have O(n) growth rate performance, while the add, remove, contains, and size operations of a HashSet/HashMap have a more preferable constant, or O(1) performance. I explain how this works: through HashCodes, and what a hash code is. I perform a live example by showing a magnet collection, stored in a theoretical array, versus stored in a HashMap.
    Hashcode Details from this video example:
    New Zealand :: -244247871
    Queens :: -1864844631
    Isle of Man :: 449363438
    London :: -2013264328
    Coventry :: -287223480
    Rio :: 82168
    Monterrey :: 702301905
    Peru :: 2483992
    Zurich :: -1606791497
    Sydney :: -1803913660
    R: 82
    i: 105
    o: 111
    Space 0 :: -2013264328 :: -1819295312
    Space 1 :: -1819295312 :: -1625326296
    Space 2 :: -1625326296 :: -1431357280
    Space 3 :: -1431357280 :: -1237388264
    Space 4 :: -1237388264 :: -1043419248
    Space 5 :: -1043419248 :: -849450232
    Space 6 :: -849450232 :: -655481216
    Space 7 :: -655481216 :: -461512200
    Space 8 :: -461512200 :: -267543184
    Space 9 :: -267543184 :: -73574168
    Space 10 :: -73574168 :: 120394848
    Space 11 :: 120394848 :: 314363864
    Space 12 :: 314363864 :: 508332880
    Space 13 :: 508332880 :: 702301896
    Source code is freely available on GitHub: github.com/dis...
    This video is part of a playlist on Microservices and Spring Boot with IntelliJ IDEA: • IntelliJ IDEA, Git, Gi...

ความคิดเห็น • 152

  • @lolsensei9811
    @lolsensei9811 2 ปีที่แล้ว +15

    I have scoured the internet and let me tell you that this example is the most accessible, thoroughly explained, and context provided / derived answer I have found on this topic. If the other videos on this channel are in the same ballpark, then I think I found the best edu source for me on coding concepts. Thank you so much for this well put together video.

    • @discospiff
      @discospiff  2 ปีที่แล้ว +2

      Wow! This is one of the nicest compliments I've received on my channel. Thanks so much for your feedback! That helps me to improve future videos. I encourage you to check out my channel and let me know what you think of them.
      I hope you're building something amazing! If so, let me know!

  • @skatershaner
    @skatershaner 3 ปีที่แล้ว +7

    The intelligent thinking that has laid all the groundwork for computing is simply amazing.

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      I absolutely agree. Computing is based on many generations of compound knowledge.

  • @vaneetsharma735
    @vaneetsharma735 3 ปีที่แล้ว +26

    One of the best explanations of hash map computing :) love it. Thank you

    • @discospiff
      @discospiff  3 ปีที่แล้ว +2

      Thanks! It's a great concept, and it's easy to explain... at least, I think so.

  • @james00783
    @james00783 4 หลายเดือนก่อน

    This is the 5th video today I am watching to understand time complexities and somehow none of the other videos explained these details in such a simplified way. I have been following you for a long time, your videos have been helping me a lot with the topics that are not explained easily by the rest of the internet. A big big thanks to you for grasping all the concepts correctly and then explaining them to us in such an amazing way.

    • @discospiff
      @discospiff  4 หลายเดือนก่อน +1

      Thanks so much! I really appreciate the feedback!
      This was one of my favorite videos to record.
      I ended up making several more videos about Big O algorithm growth as well. Let me know if I can help you find a topic of interest!

    • @james00783
      @james00783 4 หลายเดือนก่อน

      @@discospiff I am trying to master DSA to become a better programmer. I an currently exploring DS, will explore algorithms soon. I have an interview in 4 days that I really want to dominate. I will be exploring your channel for related topics

    • @discospiff
      @discospiff  4 หลายเดือนก่อน

      @@james00783 excellent, and great idea!
      I have a playlist with Data Structures and Algorithms videos only. Have a look, and let me know if you have any questions. I'm happy to help!

    • @james00783
      @james00783 4 หลายเดือนก่อน

      Sounds great. Thanks. Any doubt, I'll let you know.

  • @MrLuigiBean1
    @MrLuigiBean1 ปีที่แล้ว

    This video was fantastic, really cleared all of my doubts! (what really is a hashcode, difference between hashset and hashmap, how time complexity stays at O(1) always) Thank you very much! 👍

    • @discospiff
      @discospiff  ปีที่แล้ว

      You're welcome! Thanks for watching. I'm happy to know that this video is doing what I had hoped it would do - make HashCode, HashMap, HashSet, and Big-O notation easier to understand.

  • @CanopusInfinity
    @CanopusInfinity 2 ปีที่แล้ว +7

    A phenomenal video and explanation for these concepts. It is amazing how easy some concepts are using real-world objects. Thank you for sharing your knowledge with us.

    • @discospiff
      @discospiff  2 ปีที่แล้ว +2

      Thanks for watching. This is one of my favorite videos!

  • @1990lietuva
    @1990lietuva ปีที่แล้ว

    Amazing video, explained it very well. I was scratching my head trying to grasp the concept, but now I understand it perfectly.

    • @discospiff
      @discospiff  ปีที่แล้ว

      Excellent! Thanks for the feedback. That helps me to plan future videos. Several more on this topic coming soon!

  • @yoteapoyo
    @yoteapoyo 2 ปีที่แล้ว

    Wow! wow! Excellent clarification!
    Great introduction also to this video: "Static Hashing, Array vs Hash, Collisions, Overflow Chains, Rehash".

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks for sharing!

  • @justinchan340
    @justinchan340 3 ปีที่แล้ว +9

    Thank you, your video made understanding HashMap runtime quick, easy, and enjoyable

    • @discospiff
      @discospiff  3 ปีที่แล้ว +3

      I'm happy to hear that! It was a fun video to make.

  • @pnworks9186
    @pnworks9186 2 ปีที่แล้ว

    One of the best explanations I saw. Thank you Sir.

    • @discospiff
      @discospiff  2 ปีที่แล้ว +1

      Thanks! I really appreciate your feedback. It keeps me motivated to make more, and better, videos!

  • @egonisnoise
    @egonisnoise 2 ปีที่แล้ว +1

    Very good and straight forward explanation without compromising on the whole concept! Thank you for making me appreciate hash tables!

    • @discospiff
      @discospiff  2 ปีที่แล้ว +1

      Thanks! I'm glad you appreciate the video. Understanding Big O is fundamental to being an expert software architect.

  • @michaelkamen1879
    @michaelkamen1879 3 ปีที่แล้ว

    Great peek into the depth of Collections jungle and all without a machete or a chopper! Bravo! The transient mustache and repeated mention of the "Bureau of Murderous Vehicles" were nice touches for making sure one's attention does not wander.

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Thanks! That was my goal when I made the video: explain HashMaps and big O in a simple way, and do something subtle to keep attention. I'm glad you noticed!

  • @chandnibhatia316
    @chandnibhatia316 2 ปีที่แล้ว

    The perfect video on Hashset. I found everything I was looking for. Thankyou sir!!

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      That's great to hear! This is one of my favorite videos. What we're you looking for? :)

    • @chandnibhatia316
      @chandnibhatia316 2 ปีที่แล้ว

      @@discospiff I wanted to know why time complexity of hashset is that low and if it is because of hashcode then how does it function which I understood because of you so thankyou once again 🤜🤛

  • @clovenstone100
    @clovenstone100 3 ปีที่แล้ว

    Very good demonstration of hashing and bucketing

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Thanks for watching! I'm glad it helped.

  • @phoenixone7450
    @phoenixone7450 3 ปีที่แล้ว +1

    It is definitely the best video about HashMaps I have found so far.

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      Thanks! I'm glad you found it. :)

  • @Dennis-Ong
    @Dennis-Ong 3 ปีที่แล้ว

    I kept wondering why hashMap is so fast under neath it, i couldn't comprehend it just memorize it. Thank you mr brandan, you helped me.

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Glad it helped! It's a very powerful concept, especially when growth of data is unpredictable. I think it makes a lot of sense once you understand it.

  • @indranildutta4252
    @indranildutta4252 2 ปีที่แล้ว

    Love the layman explanation, Understood to the core … this kind of explanation rare in world of fancy jargon that i frequent always...

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! That's really good feedback. I'm glad this video helped you to understand the big-O concept. It's very powerful!

  • @kasamadhu3509
    @kasamadhu3509 ปีที่แล้ว +1

    great explanation , Thank you

    • @discospiff
      @discospiff  ปีที่แล้ว

      Thanks! Big O is an important concept in programming for scalability, and this was one of my most fun videos to make. I'm glad you enjoyed it!

  • @muriloschuck4738
    @muriloschuck4738 3 ปีที่แล้ว +3

    damn. i was not expecting to see a so good explanation. thank you very much for sharing this, the didacticism is spectacular! greetings from brazil.

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      Thanks! I appreciate your feedback. I enjoyed making this video.
      I've been to Brazil, and I currently work with two people who live in Brazil!

  • @karandedhiya727
    @karandedhiya727 2 ปีที่แล้ว +1

    Thanks for this video. The explanation technique is very nice and simple. I got the concepts very quickly. Keep sharing such videos 👍

    • @discospiff
      @discospiff  2 ปีที่แล้ว +1

      Thanks! I really enjoyed making this video. Comments like yours give me the motivation I need to make more. Stay tuned!

  • @riki2404
    @riki2404 2 ปีที่แล้ว

    Beyond brilliant. Thank you so much. I understand visually much better than by reading so this was really useful.

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! I appreciate the feedback. When I planned this video, I thought visuals / analogy would be a good way to describe a complicated concept. ;)

  • @AIToolzai
    @AIToolzai 2 ปีที่แล้ว

    one of the best explainations of hash map/set. seems like you made a lot of effort in making this over several weeks. thank you

    • @discospiff
      @discospiff  2 ปีที่แล้ว +1

      I really enjoyed making the video. I appreciate your feedback... glad you found it helpful!

  • @reciklaza
    @reciklaza 2 ปีที่แล้ว

    This is how you explain things. Brilliant! Thanks

    • @discospiff
      @discospiff  2 ปีที่แล้ว +1

      Thanks for the feedback! I'm happy that you found the explanation helpful.

  • @RohitSharma-vq2gn
    @RohitSharma-vq2gn 3 ปีที่แล้ว +1

    Became a fan of your lucid and practical explanations ! Thanks for sharing!

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      Excellent! I appreciate the feedback. If you keep watching, I'll keep making videos. :)

  • @chiragpatil2038
    @chiragpatil2038 ปีที่แล้ว

    Very nice explanation, Great Video. Thank you

    • @discospiff
      @discospiff  ปีที่แล้ว

      Thanks! What did you like about it?

  • @norulesprateek
    @norulesprateek 4 ปีที่แล้ว +1

    Very helpful. Smooth explanation.

    • @discospiff
      @discospiff  4 ปีที่แล้ว +1

      Glad it was helpful! It was a fun video to make.

  • @xqiu5627
    @xqiu5627 4 ปีที่แล้ว +1

    Thank you Mr.Jones for this great video

    • @discospiff
      @discospiff  4 ปีที่แล้ว

      You're welcome! Thanks for watching and commenting.

  • @violets9785
    @violets9785 2 ปีที่แล้ว

    Thank you so much for this great video. Much appreciated your work.

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! I'm glad you like it. This is one of my favorite videos... and understanding HashMap and hash codes is very important!

  • @jorgesuspes5816
    @jorgesuspes5816 3 ปีที่แล้ว +1

    Very nice explanation, good use of visuals as well. Thanks!

    • @discospiff
      @discospiff  3 ปีที่แล้ว +2

      Thanks! I think this subject is best explained visually, so it's great to hear that feedback. Did you notice my growing beard? ;)

  • @joshuaalharrison
    @joshuaalharrison 2 ปีที่แล้ว

    Great explanation, but....nobody's going to talk about the gradually increasing facial hair throughout the whole video? Very fun addition!

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      LOL, thanks for noticing. I do that in all of my videos.
      While it's not as obvious in low light, I shaved 5 times to make this video.

  • @marianopatino-paul5062
    @marianopatino-paul5062 3 ปีที่แล้ว

    Amazing explanation

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Thanks, I'm glad you enjoyed it! That's exactly what I was trying to achieve with this video.

  • @SamBebbington
    @SamBebbington 3 ปีที่แล้ว +1

    Brilliant explanation!
    The moustache took me by surprise tho!

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Tusks for noticing. I shaved 5 times while recording this video, so there are 5 different transitions. Unfortunately, some are in low light, so it's hard to tell. :)

    • @SamBebbington
      @SamBebbington 3 ปีที่แล้ว

      @@discospiff The full beard at the end looks the best, really suits you!

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      @@SamBebbington That's what my wife says. :) Naturally, I had to record the video on reverse order, which was a little tricky. Here's another one I did, where the lighting is a bit better: th-cam.com/video/l6O2oewO43g/w-d-xo.html

  • @NitaNair
    @NitaNair 3 ปีที่แล้ว

    Thank you for the nice explanation Mr.Jones

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Thanks! Do you have a favorite part?

  • @Ankitkiller420
    @Ankitkiller420 3 ปีที่แล้ว

    Very excellent explanation sir. Thank you very much

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Thanks for watching! I'm happy you found it useful.

  • @manelzerah
    @manelzerah 2 ปีที่แล้ว

    thank you very much for this explanation

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      I'm glad it helped! What did you learn from it?

  • @ashwanishukla8029
    @ashwanishukla8029 2 ปีที่แล้ว

    Love from india ,so easily explained

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! That is wonderful feedback.

  • @Михаил-и1з6м
    @Михаил-и1з6м 4 ปีที่แล้ว +4

    Thank you for a very educative tutorial)

    • @discospiff
      @discospiff  4 ปีที่แล้ว +1

      Glad it was helpful! Big-O is one of my favorite topics: how you can get more growth with the same amount of hardware. It's also a neat intersection of math and computing, IMHO. So, for those who like programming, and not math, I think Big-O is a good way to show how they relate.

    • @Михаил-и1з6м
      @Михаил-и1з6м 4 ปีที่แล้ว

      I am newbie in Big O topic, looking forward for more Big O tutorials)

    • @discospiff
      @discospiff  4 ปีที่แล้ว +1

      Excellent. Here's one I made a month ago, which is the part 2 to the video you're watching: th-cam.com/video/mTpsxbplg14/w-d-xo.html
      I know I made them out of order. :)

  • @ryazhartur
    @ryazhartur 2 ปีที่แล้ว

    Thank you! This video explains A LOT.

    • @discospiff
      @discospiff  2 ปีที่แล้ว +1

      I'm really happy to hear that feedback! That was my goal for this video.

  • @trois4ever6
    @trois4ever6 3 ปีที่แล้ว +1

    thank you for your efforts, i loved your way of presentation so much.

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      Thanks! This is one of my favorites. :)

  • @AndItBegins
    @AndItBegins 2 ปีที่แล้ว

    Great teaching with good examples. Loved it, Thank you :)

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! This is one of my favorite videos. I enjoyed making it.

  • @andreasgerhards1655
    @andreasgerhards1655 3 ปีที่แล้ว

    really good explanation and really good visualisation.
    LOVE IT

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      Thanks! I think visualizations help understand complicated topics like Big-O notation and algorithms. I'm glad you liked it.

  • @Dr.MDr.
    @Dr.MDr. ปีที่แล้ว

    Great Video! Thank you very much!

    • @discospiff
      @discospiff  ปีที่แล้ว +1

      Thanks! This is one of my favorites. ;)

  • @kankanarock3443
    @kankanarock3443 2 ปีที่แล้ว

    Thank You! This was really helpful.

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! I'm glad it helped. Understanding big-O is fundamental to understanding scalability, in my opinion.

  • @david_ramoraswi1711
    @david_ramoraswi1711 2 ปีที่แล้ว

    best explanation everrrr

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! I had a lot of fun making this video. I'm glad you found it useful!

  • @jonstewart5525
    @jonstewart5525 3 ปีที่แล้ว

    Just a side note, at 2:55 you say we typically think worst case for big O notation. Big O notation states that the complexity is less than or equal to the expression given. Little o is strictly less than, Omega notation is greater than, and theta notation is equal to

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Really good info! Thanks! I simplified things a bit in this video... and your explanation really helps.

  • @leandroribeiro5147
    @leandroribeiro5147 ปีที่แล้ว

    Great explanation! I do have one question: how does multiple objects residing in the same bucket affects time complexity, if at all?
    If I have a bucket with 100ths of objects, will it change things? Or will the buckets just get auto-split?

    • @discospiff
      @discospiff  ปีที่แล้ว +1

      It will impact performance, yes. There are three options if multiple objects end up in the same bucket:
      1) Put a List in that bucket, and store them in the list.
      2) Put the objects in the next empty bucket.
      3) Increase the capacity of the HashMap/HashSet, and reallocate buckets.
      If you really had 100 objects in the same bucket, #3 is the most likely scenario.
      This is a one time performance hit, during reallocation, where #1 and #2 would have a slight performance impact on every lookup and retrieval.

  • @themindsculptor_
    @themindsculptor_ 3 ปีที่แล้ว

    This is super good. Thank you for your time

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      I'm glad it helped! It was a fun video to make. Thanks for the comment!

  • @vimalk2661
    @vimalk2661 2 ปีที่แล้ว

    Great Explanation.

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! I really like hearing that feedback.

  • @macawls
    @macawls 2 ปีที่แล้ว

    Thanks so much this was excellent.

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! What did you like about the video?

  • @Sailgodgreenearth
    @Sailgodgreenearth 2 ปีที่แล้ว

    one of the beautiful videos I have seen on this topic. But what happens when at a particular index we have two values??

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks! I'm glad you liked it. Is there anything specific you like about it? Your feedback helps me improve future videos.
      I'll say, this is one of my favorite videos. ;)

  • @270MinutesLater
    @270MinutesLater 2 ปีที่แล้ว

    Thanks, I feel like I know everything now:)

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Thanks for the comment! I'm happy to know that this video has helped many people.

  • @MethodOverRide
    @MethodOverRide 2 ปีที่แล้ว

    Amazing video!!

    • @discospiff
      @discospiff  2 ปีที่แล้ว +1

      Thanks! It's one of my favorites.

  • @devchawda9414
    @devchawda9414 3 ปีที่แล้ว

    Amazing video sir , you earned my subscribe.

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      That's great to hear! It's always nice to have another subscriber.
      What did you like about the video?
      I had a lot of fun making it. :)

  • @marco4570
    @marco4570 2 ปีที่แล้ว

    Excellent!

    • @discospiff
      @discospiff  2 ปีที่แล้ว +1

      Thanks! This is one of my favorite videos. :)

  • @everiguado5272
    @everiguado5272 3 ปีที่แล้ว

    This is amazing, very very good work. Suscribed.

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Excellent, I'm glad to like it! Thanks for watching.

  • @samueljames3257
    @samueljames3257 3 ปีที่แล้ว

    Really really good stuff. Keep it up

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      I'm glad you found it. I'm thinking of making a video on Huffman encoding. Any other ideas... let me know! Thanks.

    • @samueljames3257
      @samueljames3257 3 ปีที่แล้ว

      @@discospiff That sounds super interesting. Would for sure watch! :D

  • @manikantaammula9279
    @manikantaammula9279 3 ปีที่แล้ว

    Your incredible.it was a great explanation.

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      Thanks! It was a fun video to make.

  • @melissamunoz517
    @melissamunoz517 2 ปีที่แล้ว

    Thank you!

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      You're welcome! I'm glad you enjoyed it.

  • @musa4747
    @musa4747 3 ปีที่แล้ว

    golden. Thank you boss

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      You're welcome! It was a fun video to make. Thanks for watching!

  • @Ash-so2sr
    @Ash-so2sr 3 ปีที่แล้ว

    thank you great explanation!!!

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      Thanks! I'm glad you found it useful. I appreciate the comment.

    • @Ash-so2sr
      @Ash-so2sr 3 ปีที่แล้ว

      @@discospiff cool mustache too my friend

    • @discospiff
      @discospiff  3 ปีที่แล้ว

      @@Ash-so2sr Thanks. I had planned that one for while. I actually did it in 5 steps, but the ones with the magnets are hard to see, due to the lighting.

  • @iuliqt
    @iuliqt 4 ปีที่แล้ว

    Great video!

    • @discospiff
      @discospiff  4 ปีที่แล้ว

      Glad you enjoyed it. I enjoyed making it. :)

  • @mikemel3459
    @mikemel3459 2 ปีที่แล้ว

    12:00 lost me here... I'm a visual person.
    Can someone please type out the math in a programmatic way?
    For example: This is the way I understood it
    bucketNum = (hashcode - lowestPossibleHashcode) / Total number of buckets?
    Is this correct? And how do you determine the lowest possible hashcode?

  • @lukostello
    @lukostello 3 ปีที่แล้ว

    why is it 31? The method I would have came up with to determine the bucket would be to use floor(fmod(golden ratio * key's binary representation), 1) * number of buckets)

    • @discospiff
      @discospiff  3 ปีที่แล้ว +1

      You got me thinking...
      When I taught Data Structures and Algorithms, I recall the text mentioned that 31 just happened to work out well, as it is an odd prime number. I often wondered why 31. Maybe it has something to do with the number of letters in the alphabet? No, probably not, because uppercase and lowercase are treated differently. Plus there are special characters and symbols.
      I never knew the answer, so I just searched. I found an interesting answer on Stack Overflow, which references the book Effective Java. Here it is:
      "The value 31 was chosen because it is an odd prime. If it were even and the multiplication overflowed, information would be lost, as multiplication by 2 is equivalent to shifting. The advantage of using a prime is less clear, but it is traditional. A nice property of 31 is that the multiplication can be replaced by a shift and a subtraction for better performance: 31 * i == (i

    • @lukostello
      @lukostello 3 ปีที่แล้ว

      @@discospiff using the golden ratio probably wouldn't perform as well. But I bet I'd get a more even distribution. Maybe mine could have fewer collisions. Might test some day.

  • @dhineshkumars1991
    @dhineshkumars1991 2 ปีที่แล้ว

    Can you paste the formula on how you are reaching 12th element ,,I'm finding it difficult if we subtract 2.1 billion with 450million how would we reach 2.5 billion can you please paste the formula with an example ,,but what an awesome way to teach the Order of () in a simple approach ,,kudos 👍🏻💯

  • @mpsniper9316
    @mpsniper9316 2 ปีที่แล้ว

    ِِDoesn't it take O(logn) to find the span in which to put the new City in HashMap? I mean it would be a binary search to locate where should put the City by it's number.
    Can anybody explain???

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      I tend to see log in Big-O when something recursive happens, like a Merge Sort. There's nothing recursive here; it's simply navigating directly to the location in the HashMap based on an algorithm, so that's O(1).
      Things get a bit more complicated if you are inserting something, and there is already something in that spot, or when you have to reallocate the HashMap. But, if you're just inserting into a compartment where nothing else exists, you're not bothering the other elements, so it's a simple O(1).
      Does that make sense? Or is my math incorrect? That's completely possible, too. :)
      See this video for an explanation on Big-O that has a logarithm: th-cam.com/video/mTpsxbplg14/w-d-xo.html

  • @KennyNissel
    @KennyNissel 4 ปีที่แล้ว

    Yo great video man

    • @discospiff
      @discospiff  4 ปีที่แล้ว

      Thanks! I had a lot of fun making it. :)

  • @White_King
    @White_King 2 ปีที่แล้ว

    why there is no HashList? o.O

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Because a list would indicate an ordered collection. A hash would indicate but an ordered collection. That's why it's a set or a map.

  • @merlinay5640
    @merlinay5640 2 ปีที่แล้ว

    I have the same magnets

    • @discospiff
      @discospiff  2 ปีที่แล้ว

      Which ones? I have a lot of magnets. :)

  • @Bob-zg2zf
    @Bob-zg2zf 4 ปีที่แล้ว

    Please put your mic on your body for a better production quality. Thank you.

    • @discospiff
      @discospiff  4 ปีที่แล้ว +2

      I don't have a wireless mic, but since I'm doing more standup videos, I do want to get one!

  • @mdsujan6686
    @mdsujan6686 2 ปีที่แล้ว

    hi beard work tho.

    • @discospiff
      @discospiff  2 ปีที่แล้ว +1

      Thanks for noticing! I do that in several of my videos.

    • @mdsujan6686
      @mdsujan6686 2 ปีที่แล้ว

      @@discospiff 😍