#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... - Наука та технологія
Hi Naveen, I am not clear about the Red And black Nodes. How do you mark a node as red? or black?
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.
Best video on TreeMap. One observation - Red-black tree is a balanced Binary Search Tree not just balanced Binary Tree.
everything is good, but got ambiguity in which node has to mark as red, which node has not to?
Great explanation. Thanks for your efforts :).
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
Thanks for the video. But I think the example at 21:10 is not a Balanced BST. Am I incorrect?
Yeah, it is not balanced. The right side of James is Paul . From Paul left is Larry and right is Ted
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!..
*tree
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.
Hi Sir, Its clear for now. but i couldn't understand if suppose if two names are similar how the tree will be sorted?
TreeMap doesn't allow duplicate keys and as tree is built bases on keys there will no be two similar keys.
Bro you are the best thing i found on youtube in first part of december
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 :(
If you have given class name as TreeMap(). then it will conflict with Java.util.TreeMap. Try changing the class name.
great explained
🙌🙌🙌awsm
Superb ..!!!
Thank you! Cheers!
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?
You will have to implement equals and hashcode method and pass a comparator
Very easily explained
Keep watching
@@naveenautomationlabs sure sir!
Great job!
Iwas asked in an interview about printing the Treemap in reverse order.
how did you do that?
@@letmehink166 you can write the tree map with comparator.reverseOrder();
.descendingMap() should work of TreeMap class
use comparator class
G 0:12