How the get(Key k) method works within a HashMap|| Part 3

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024
  • In this tutorial, we will cover how the Get method of Hashmap works.
    Before watching this tutorial Please watch the part 1 of this series at the below link.
    How hashmap works internally (Overview)
    • How HashMap works inte...
    practical of Hashmap Internals
    • [PRACTICAL]How Hashmap...
    subscribe to my channel by clicking on the link below.
    / @seleniumexpress
    Stay tuned and like my Facebook page for more.
    / seleniumexpress
    Music :
    -----------
    credits : -
    1)
    Adventures by A Himitsu / a-himitsu
    Creative Commons - Attribution 3.0 Unported- CC BY 3.0
    creativecommons....
    Music released by Argofox • A Himitsu - Adventures...
    Music provided by Audio Library • Adventures - A Himitsu...
    (intro)
    2)
    NCM Epic Music Ender Guney
    / ncmepicmusic
    -----
    intro template :
    wth-cam.com/users/Alexbau01

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

  • @suhasnayak4704
    @suhasnayak4704 5 ปีที่แล้ว +21

    Update: From Java 8, when different keys hash to the same bucket and when the bucket capacity reaches its TREEIFY_THRESHOLD(8), the nodes in bucket will be stored in a balanced binary tree structure thereby reducing the worst case time complexity to O(log n) from O(n). When nodes in the bucket starts getting reduced and when the number of nodes in bucket reaches UNTREEIFY_THRESHOLD(6), the nodes in a bucket will again be stored in a Linked List structure.

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

    The way of teaching is very understandable sir. Thanks for Ur valueble video. Great job.

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

    Thanks a lot for teaching this way, I believe it makes a huge difference when you include graphical representation, thanks again!

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

    wow... after trying so many channels, today it got cleared. Thanks buddy :) keep posting interview questions answers like this.

  • @saravanakumarramanujam8360
    @saravanakumarramanujam8360 6 ปีที่แล้ว +8

    I saw many videos before for HashMap internal explaination, but this is the best . You explained it very well with nice and simple examples. Hope you cover moe important topics(Interview perspective topics) in future. All the best

    • @SeleniumExpress
      @SeleniumExpress  6 ปีที่แล้ว

      You are awesome.Glad to know that these videos helped you.Thank you, Saravana, for posting such a lovely comment.

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

      True !!! Completly agree

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

    Thanks a lot for this video. 4 years doubt got cleared.

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

    I watched lots of video but this channel is different from all. your way of teaching is very familiar thank you for sharing knowledge with us.

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

    Very good explanation,keep it up.

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

    I have not cleared my 2nd interview round because of this nd couple more.. But now i am much confident about this concept... Thanks

  • @igpYT
    @igpYT 5 ปีที่แล้ว

    I have watched several videos on TH-cam but trust me it make sense to me. Very well derived and executed. Thanks

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

    Wow wonderful explanation 🤗

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

    Very useful , thanks for sharing

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

    Awesome video bro.All three videos are good

  • @SaravanaKumar-mi6pr
    @SaravanaKumar-mi6pr 5 ปีที่แล้ว

    Excellent sir 👌👌👌👌👌

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

    Thanks you so much its very crystal clear explanation .

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

    Thank you so much for explaining clearly

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

    Very nicely explained

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

    Wonderful explaining skills you have, thanks for making this so easy to understand.

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

    Your great bro love you lot ❤️❤️ keep doing more

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

    Awesome explanation

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

    Superb explanation

  • @manideepkumar959
    @manideepkumar959 6 ปีที่แล้ว

    Ur reallly teaching excellently i dont know y this channel is not popular yet

    • @SeleniumExpress
      @SeleniumExpress  6 ปีที่แล้ว

      Thanks Manideep..
      And yes if there will be some people like you around me, who are giving some positive motivations all the time, then one day this channel will achieve it's goal 😊

    • @manideepkumar959
      @manideepkumar959 6 ปีที่แล้ว

      Sure trainer, i will forward these video links who r reallly wants to learn kava in deep, morover ur teaching is very effective on board i could involve that i am in class

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

    I like the way you explained and it will be more useful to everyone.You are having much talent i believe,please do more videos with good concept.

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

    Great job🥰it was very helpful 💕💕Thank you

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

    Thank you very much doing this video for us, it's mandatory interview question, with your explanation I will hit the interviewer like anything, good explanation and practical experience. Keep rocking🎸🎶🎶

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

    You explained very good way n make easy this topic. Thank you shared with us your knowledge.

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

    Nice Explanation..

  • @amanshaikhh7
    @amanshaikhh7 11 หลายเดือนก่อน

    Thanks for All Hash Map videos!🤝

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

    Thank you for your efforts 🏆🏆

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

    Thank you for clear explanation

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

    Thanks bro. You taught hashmap very easily.

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

    Nice explanation brother

  • @amankumar-hg6ul
    @amankumar-hg6ul 3 ปีที่แล้ว

    awesome explanation,thanks buddie

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

    Love your all videos !!🤘

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

    Awesome hero

  • @s.keerthanakeerthana7143
    @s.keerthanakeerthana7143 4 ปีที่แล้ว

    Very nice explanation 👍
    Thank you very much🙂🙂

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

    Awesome,very good explanation . Keep it up bro and thank

  • @gauravpatil7989
    @gauravpatil7989 5 ปีที่แล้ว

    Very Nice Explanation ,i clear all my doubts Thank You So much keep it up

  • @suryakantmaharana8544
    @suryakantmaharana8544 5 ปีที่แล้ว

    very nice explanation sir ,Thanks a lot for making me clear the internal working of HashMap.

  • @Mk-br5bj
    @Mk-br5bj 5 ปีที่แล้ว

    Hey Crystal clear explanation yar... Thanks a lot....

  • @bhaskarmarepalli2448
    @bhaskarmarepalli2448 6 ปีที่แล้ว

    very good explanation in 3 parts, thanks for creating video

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

    well explained

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

    awesome

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

    Well explained...👍

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

    Awesome explaination

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

    Superb sir, I really felt happy seeing this video

    • @SeleniumExpress
      @SeleniumExpress  6 ปีที่แล้ว

      Thanks, Mate.. You happy, I happy 😊

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

    Ur explanation is superb, whole concept got cleared , u should kon make full course of java

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

    Can you please make a video on how to make our own hashmap in java. (some internet contents suggest it using linked list and creating our own class). Please make a video on that as an extension to this playlist.

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

    thanks, you explained this very well

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

    thank you !!!! the best

  • @anandjha5353
    @anandjha5353 6 ปีที่แล้ว

    Superb tutorials. Thread tutorials would be very helpful. Thanks!

  • @subramanyamsattenapalli4720
    @subramanyamsattenapalli4720 6 ปีที่แล้ว

    Very nice and simple explanation

  • @bhalchandragiri9858
    @bhalchandragiri9858 5 ปีที่แล้ว

    Great tutorial... got good amount of knowledge...Thanks

  • @jayrami1295
    @jayrami1295 5 ปีที่แล้ว

    Nice

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

    So I am going to echo the people who commented to please not call the nodes of a linked list linked lists. Nodes are individual elements. Now it is true, that sometimes, but not often, we will call nodes of a tree "Tree Nodes" but in that case it is tempting because it is only a total of two syllables and still isn't that common, we usually just say "nodes". For Linked Lists it is way, way, worse, because "Linked List Nodes" is too long and too many syllables. But the whole list itself only is called the Linked List, or perhaps some segment of it like the last five elements. Technically, any subset of a linked list could be considered a linked list, but really, the best thing to do is to only ever call the whole thing a linked list and the individual nodes just a node. If we took this example all the way and got enough collisions so that some of the buckets pointed to trees and others pointed to linked lists, there would be some excuse for calling that first reference "a linked list" because if we said node one would wonder whether we meant linked list or a tree. But even there, I would only call the first reference in each bucket a linked list (or a tree), anything linked in past that is just a node. Yes, technically the linked list is a doubly linked list, but that really doesn't change how confusing that seemed to be to some beginners. Even myself it caused me to get startled enough thinking whether you meant to say "linked list" or "node" that I had to stop the video and go back in a few different places. Overall, it is excellent, I just wanted to complain about that terminology sloppiness because I thought it detracted from the educational usefulness of the video for beginners.

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

    Really sir it's awesome explanation.... and....also thank you so much sir@@@

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

    Can u plz upload video regarding linkedhashmap, as u explain each and every concept in detail and it is easy to understand thank u for making such videos.

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

    Very Well Explained. I just have a one question. How will hashcode will be calculated after size of table is increased? lets say I inserted key "AAA" while size was 16 and now I'm trying to get "AAA" and current size of table is 32.

  • @NambiarRam
    @NambiarRam 6 ปีที่แล้ว

    excellent explanation of hashmap

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

    Code from open JDK :
    if (Objects.equals(key, e.getKey()) &&
    Objects.equals(value, e.getValue()))
    Meaning we compare key & value in equals method to determine the uniqueness of an Object.

  • @Justrandom1610
    @Justrandom1610 5 ปีที่แล้ว

    Awesome explanation...

  • @priyankashinde1424
    @priyankashinde1424 5 ปีที่แล้ว

    love you the way u r explaining great work!

  • @gurmeetchawla8362
    @gurmeetchawla8362 6 ปีที่แล้ว

    please also cover the scenario as to what happens to hashcode and their buckets when the map resizes

  • @sulavagarwal3561
    @sulavagarwal3561 6 ปีที่แล้ว

    Very Good Explaination

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

    Great!

  • @skellaskella8784
    @skellaskella8784 6 ปีที่แล้ว

    superb explanation.. thanks a lot sir. very clear cut explanation. if it possible provide some data structure algorithms sessions.

  • @bheemay817
    @bheemay817 6 ปีที่แล้ว

    Excellent sir.....

  • @dileepkumar-pw3gh
    @dileepkumar-pw3gh 6 ปีที่แล้ว

    Hi Bro,
    Cool bro... Thank you so much..
    Cool information... Keep rocking😊👍

  • @manishpatidar5379
    @manishpatidar5379 5 ปีที่แล้ว

    awesome, well explained..

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

    Nice explanantaion Sir :)

  • @AdityaKumar-vp1xi
    @AdityaKumar-vp1xi 3 ปีที่แล้ว

    So as you told in your previous videos that we have initially 16 bucket and to identify the bucket within that range it uses mod 16 to get appropriate bucket and when it reaches to threshold it doubles the size of bucket and according to you it uses mod 24 with hashcode to get appropriate bucket no, and here is a question " let assume that we have 13 elements in hashmap so the first 12 elements goes into the bucket by hash(hashcode%16) and remaning goes into bucket hash(hashcode%24) so at the time we call the get method what would be the hash function to select the right bucket"

  • @dilipnathrani8014
    @dilipnathrani8014 6 ปีที่แล้ว

    awesome explanation bro

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

    Sir ,I also need tree map internal working, Please upload vedio of tree map internal working

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

      have u got any good video for internal working of tree map , even i am searching that

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

    @Selenium Express Could you please add a video on how hashset works internally and how put works in hash map

  • @amitaswar3195
    @amitaswar3195 6 ปีที่แล้ว

    nice yaar.......

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

    Sir,
    As I noticed that first you use the string object "abc" as a key to put in map after that u use the string object "abc" as a key to get the value of it.
    But here I have one doubt that, as string is immutable then definitely both "abc" string object should have the different hashcode then how is this possible to get the same hashcode value again in hashmap to get the value of it

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

      String class has overriden equal method for content comparison . Their is Contract between equals() and hashcode() in Java. If two objects even with different refrence are equal (as in your example ) , then their hashcode must be equal .

  • @shekark1223
    @shekark1223 6 ปีที่แล้ว

    Good explanation

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

    How it returns index 4 ? We have the hash and how to know with what should we compare it to ?

  • @SaiSVolgs
    @SaiSVolgs 6 ปีที่แล้ว

    nice explanation boss

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

    How to calculate hash code and index for a particular key and value paire

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

    Thank you so much!

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

    If we are comparing key using equal(), then what is the use of storing hashcode inside node. It is redundant. Please let me know

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

      hi, in case of hash code Collison case, the hashcode value will be same, by using the equals method only we can do compare the key name and get the value from correct Node. hope it clarify the concern. thank you.

  • @tominpmarkose
    @tominpmarkose 5 ปีที่แล้ว

    During get operation, once we calculated the index using hashcode why there is again a check for finding the target from linked list?. Obviously the hashcode for all the Nodes and the value passed to get method is same (that's how we computed the index). So cant we just check only equals() . ?

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

    Perfect ✌🏻

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

    As you used strings for keys, when a put method is invoked e.g. map.put("abc",1); the hash code for key "abc" will not calculate again as it calculated once when this string created, right?

  • @priojitsen135
    @priojitsen135 5 ปีที่แล้ว

    awsm bro

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

    at 4:45, why doesn't the HashMap implementation directly compare the key with the node's key using .equals()? why is it comparing the hash first, then comparing the keys with .equals() (only after it finds out that both hashes match)?
    Why does it want to compare twice instead of once to find out which node is the correct one? Thank you.

    • @narasimhabhargavvanamala3817
      @narasimhabhargavvanamala3817 6 ปีที่แล้ว

      Sir why cannot get method directly compare the string in first place instead of hascodes?

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

      In a bucket there can be many objects having different hashcode, int Hashcode comparison is easy, than equals method comparison on object i feel

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

    how to calculate index value in hashmap by using hashcode value?

  • @aimless758
    @aimless758 5 ปีที่แล้ว

    Nice Video. Can you also extend this to concurrentHashmap and differences.

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

    Bro which class equals method is going to be used here internally I mean it is of object class or string I searched alot and I found the answer as it is of object class bt obj class checks reference so plz can u tell me what is the truth m very confused 😊

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

    I have small doubt sir, we have checked two keys using equals at the time of get method. But my question is when adding value, need check equal to(hash c collision)?

  • @martineflores9604
    @martineflores9604 5 ปีที่แล้ว

    Hello sir good tutorial and explanation. How about hashtable i hope to make a video how hashtable internally works.

  • @lakhankale9692
    @lakhankale9692 5 ปีที่แล้ว

    sir please make video on sorting hashmap on basis of kay and value Please.,

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

    Thank you so much :)

  • @kuladeeppatil7460
    @kuladeeppatil7460 5 ปีที่แล้ว

    nice explanation about put/ get operations on hashmap; Do you know recurrent modification exception problem with Hashmap?

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

    You should rename channel I feel. Should be related to Java

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

    I was expecting one more case here, if key is not present in HashMap

  • @swarajgupta3087
    @swarajgupta3087 6 ปีที่แล้ว

    Why there is a need to store hashcode inside a node, when key is already there? Cant get(key) can be compared directly with the key present inside a node?

    • @manideepkumar959
      @manideepkumar959 6 ปีที่แล้ว

      Swaraj Gupta, after size doubles, all the objects who are all having an be hashcodes they will be placed into same buckets i feel

  • @smasherentertainment4643
    @smasherentertainment4643 6 ปีที่แล้ว

    please explain executor service framework

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

    I like