Comments on: Red-Black Tree (Fully Explained + with Java Code) https://www.happycoders.eu/algorithms/red-black-tree-java/ Wed, 27 Nov 2024 13:50:07 +0000 hourly 1 By: Ra https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-19107 Tue, 05 Sep 2023 16:22:16 +0000 https://www.happycoders.eu/?p=22731#comment-19107 Thanks a lot. Could you do a very short article on PostrgreSQL B-trees?

]]>
By: Sven Woltmann https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-18449 Mon, 26 Jun 2023 09:56:07 +0000 https://www.happycoders.eu/?p=22731#comment-18449 In reply to Nex.

No. But I admit that the sentence may be hard to read. Maybe better with these parentheses:

"The following example shows the shortest possible path (through a red-black tree of height four) on the left and the longest possible path on the right"

- The tree's height is four.
- The shortest possible path is on the left.
- The longest possible path is on the right.

]]>
By: Nex https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-18447 Mon, 26 Jun 2023 07:43:31 +0000 https://www.happycoders.eu/?p=22731#comment-18447 "The following example shows the shortest possible path through a red-black tree of height four on the left and the longest possible path on the right:"
Shouldn't be "height two on the left"?

]]>
By: IanTsai https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-17460 Sun, 23 Oct 2022 15:25:18 +0000 https://www.happycoders.eu/?p=22731#comment-17460 That is a clear explanation for the RB tree, Thank you for sharing.

]]>
By: Sven Woltmann https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-17301 Sun, 17 Jul 2022 18:44:45 +0000 https://www.happycoders.eu/?p=22731#comment-17301 In reply to Azhat.

Hi Azhat,

thanks so much for your message; I'm happy that my explanations helped you understand the implementation.

And thanks again for pointing out the error in case 4. I've fixed it now.

Best wishes
Sven

]]>
By: Azhat https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-17300 Sun, 17 Jul 2022 10:09:10 +0000 https://www.happycoders.eu/?p=22731#comment-17300 I was able to understand the concept of RB Tree, but when it comes to implementing in code, I was not able to understand even after going through so many sites and references.

Your explanation of implementing RB Tree in java is one of the best. It's very easy to understand and code. Appreciate your effort in writing such a detailed and nice article.

One minor correction, In Case 4: Sibling Is Black and Has Two Black Children, Parent Is Black, of deleting a node, in the second figure, sibling node should be 75 instead of 18

]]>
By: Dorian https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-17184 Sun, 03 Apr 2022 17:00:39 +0000 https://www.happycoders.eu/?p=22731#comment-17184 In reply to Sven Woltmann.

It is fixed. Still can't find where I went wrong though.

]]>
By: Sven Woltmann https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-17182 Sat, 02 Apr 2022 17:26:21 +0000 https://www.happycoders.eu/?p=22731#comment-17182 In reply to Dorian.

Deleting and then adding the same values works with my implementation.

Maybe you broke something when changing int to String. Did you make sure you're comparing the Strings correctly? With 'equals()' instad of '=='? And with 'compareTo()' instead of '<' and '>'?

If you want, you can send me your code with a test that shows the failing insert, and I'll have a look.

]]>
By: Dorian https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-17180 Fri, 01 Apr 2022 22:06:03 +0000 https://www.happycoders.eu/?p=22731#comment-17180 I have used your implementation, but when I delete some items from the tree and add them back it gives me an error that the node already exists. Only thing I have changed is the node.data to node.key for a string key.

]]>
By: Sangita Elango https://www.happycoders.eu/algorithms/red-black-tree-java/#comment-17050 Tue, 14 Dec 2021 19:47:27 +0000 https://www.happycoders.eu/?p=22731#comment-17050 In reply to Sven Woltmann.

Now I get it. Thankyou so much!

]]>