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

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 พ.ย. 2024

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

  • @socialmedia434
    @socialmedia434 4 ปีที่แล้ว +36

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

  • @spk9434
    @spk9434 4 ปีที่แล้ว +12

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

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

    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.

  • @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!..

  • @ShivamKendre-fc3su
    @ShivamKendre-fc3su ปีที่แล้ว +1

    great explained

  • @manichowdry547
    @manichowdry547 3 หลายเดือนก่อน

    Excellent

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

    Great explanation. Thanks for your efforts :).

  • @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.

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

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

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

    Very easily explained

  • @olala-j7g
    @olala-j7g ปีที่แล้ว +1

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

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

    Superb ..!!!

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

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

    • @Subeg7aryal
      @Subeg7aryal 8 หลายเดือนก่อน

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

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

    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 10 หลายเดือนก่อน

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

  • @arvindkumargupta8856
    @arvindkumargupta8856 8 หลายเดือนก่อน

    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

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

    Great job!

  • @rahulsoni-lx5rb
    @rahulsoni-lx5rb 3 ปีที่แล้ว +1

    🙌🙌🙌awsm

  • @EternalTwilight29
    @EternalTwilight29 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.

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

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

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

      how did you do that?

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

      @@letmehink166 you can write the tree map with comparator.reverseOrder();

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

      .descendingMap() should work of TreeMap class

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

      use comparator class

  • @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

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

    G 0:12