#16 - What is TreeMap? HashMap vs TreeMap || What is Red-Black Tree (Implementation of TreeMap)

Поділитися
Вставка
  • Опубліковано 31 жов 2020
  • In this video, I have explained What is TreeMap, difference between HashMap and TreeMap, What is Red-Black Tree with the actual Implementation of TreeMap.
    TreeMap is not an HashMap, hence it does not follow hashing concept.
    It's the implementation of SortedMap, which sorts the elements on the basis of Keys (By Default).
    It uses Red-Black Binary Tree to store the keys.
    For the full Java Collections videos:
    • Latest Java Collection...
    ~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    ua-cam.com/users/Naveen%20Au...
    Follow me on my Facebook Page:
    / naveenqtpexpert
    Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
    t.me/joinchat/COJqZUPB02r5sB7...
    Paid courses (Recorded) videos:
    naveenautomationlabs.com/reco...
    For Java & Selenium - naveenautomationlabs.com/selen...
    For API (Manual + Automation) - naveenautomationlabs.com/manua...
  • Наука та технологія

КОМЕНТАРІ • 33

  • @socialmedia434
    @socialmedia434 3 роки тому +35

    Hi Naveen, I am not clear about the Red And black Nodes. How do you mark a node as red? or black?

  • @KevindraSingh
    @KevindraSingh 2 роки тому +18

    This video is missing the whole core concept of R/B tree to balance the nodes to maintain a log(N) height. What you explained in this video is only the BST concept.

  • @spk9434
    @spk9434 3 роки тому +12

    Best video on TreeMap. One observation - Red-black tree is a balanced Binary Search Tree not just balanced Binary Tree.

  • @mahammadkhaja9478
    @mahammadkhaja9478 2 роки тому +1

    everything is good, but got ambiguity in which node has to mark as red, which node has not to?

  • @poonamsharma7026
    @poonamsharma7026 3 роки тому +1

    Great explanation. Thanks for your efforts :).

  • @arvindkumargupta8856
    @arvindkumargupta8856 4 місяці тому

    we have added value like
    map.put("arvind",100);
    map.put("And",90);
    map.put("duck",100);
    map.put("C",98);
    output-key=And
    key=C
    key=arvind
    key=duck
    if key is getting sorted based on alphabet then why we are getting ouput wrong ....could you please tell me

  • @olive5532
    @olive5532 2 роки тому +2

    Thanks for the video. But I think the example at 21:10 is not a Balanced BST. Am I incorrect?

    • @Subeg7aryal
      @Subeg7aryal 4 місяці тому

      Yeah, it is not balanced. The right side of James is Paul . From Paul left is Larry and right is Ted

  • @rajasekharb7901
    @rajasekharb7901 3 роки тому +3

    Good explanation and appreciated!.. But in this tutorial you didn't mentioned how to decide which node is black and which node is red. This is normal true you explained!..

  • @KaushalKumar087
    @KaushalKumar087 3 роки тому +1

    These kind of problems should never be asked in an interview. TreeMap is available in the Java library only. People using other languages will have hard time implementing TreeMap from scratch ans solving the problem also in 20-30 minutes interview.

  • @beemaraju
    @beemaraju 10 місяців тому

    Hi Sir, Its clear for now. but i couldn't understand if suppose if two names are similar how the tree will be sorted?

    • @aleksandrefimov8754
      @aleksandrefimov8754 6 місяців тому

      TreeMap doesn't allow duplicate keys and as tree is built bases on keys there will no be two similar keys.

  • @ON-tr7ki
    @ON-tr7ki Рік тому +1

    Bro you are the best thing i found on youtube in first part of december

  • @anupamasingh7366
    @anupamasingh7366 3 роки тому

    Hi Naveen, i m getting error while trying to use TreeMap --- The type TreeMap is not generic,it cannot be parameterized with arguments . Can you please explain why i'm getting like that :(

    • @ramiyamp
      @ramiyamp 3 роки тому +1

      If you have given class name as TreeMap(). then it will conflict with Java.util.TreeMap. Try changing the class name.

  • @ShivamKendre-fc3su
    @ShivamKendre-fc3su 11 місяців тому +1

    great explained

  • @rahulsoni-lx5rb
    @rahulsoni-lx5rb 3 роки тому +1

    🙌🙌🙌awsm

  • @ashuiet
    @ashuiet 3 роки тому +2

    Superb ..!!!

  • @priyankabakshi9765
    @priyankabakshi9765 3 роки тому

    Hi Naveen,
    Thanks for the video. Please let me know if we can have customized objects as keys in treemap? If yes, how would we do the sorting?

    • @lakshbk
      @lakshbk 3 роки тому

      You will have to implement equals and hashcode method and pass a comparator

  • @arnavpatil583
    @arnavpatil583 3 роки тому +2

    Very easily explained

  • @baubaudinamo
    @baubaudinamo 3 роки тому +1

    Great job!

  • @sainathvallampatla5135
    @sainathvallampatla5135 3 роки тому

    Iwas asked in an interview about printing the Treemap in reverse order.

  • @samiulislamdurjoy
    @samiulislamdurjoy 2 роки тому

    G 0:12