+ 2

Binary search tree

Can anyone show me how to balance a binary search tree please!!!

19th Apr 2018, 1:20 AM
Karen Dan
Karen Dan - avatar
6 Answers
+ 1
This is apparently one of the best algorithms for doing so: https://en.wikipedia.org/wiki/Day%E2%80%93Stout%E2%80%93Warren_algorithm
19th Apr 2018, 1:32 AM
Emma
+ 1
If it is possible, can i have some examples code on how to do it....
19th Apr 2018, 6:10 PM
Karen Dan
Karen Dan - avatar
+ 1
I've shown the code here: https://code.sololearn.com/c0sc7qsnUFo6/#cpp But it's just a straight copy of here: (except I fixed some dangling else complaints by the C++ compiler) https://www.sanfoundry.com/cpp-program-implement-self-balancing-binary-tree/ Note: It is best compiled and run from the command-line, and not in SoloLearn.
19th Apr 2018, 8:41 PM
Emma
+ 1
Tks Xan, it is a big help... hopefully i could get some help from you later if I stuck again ^-^
19th Apr 2018, 10:57 PM
Karen Dan
Karen Dan - avatar
0
Karen Dan The pseudocode is in the link I gave previously: https://en.wikipedia.org/wiki/Day%E2%80%93Stout%E2%80%93Warren_algorithm Does that help, or do you need more support? Jay's solution would certainly be excellent too â˜ș
19th Apr 2018, 6:21 PM
Emma
0
Sure, me, and I'm sure the others, will be happy to help.
20th Apr 2018, 12:35 AM
Emma