+ 2
Binary search tree
Can anyone show me how to balance a binary search tree please!!!
6 Respostas
+ 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
+ 1
If it is possible, can i have some examples code on how to do it....
+ 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.
+ 1
Tks Xan, it is a big help... hopefully i could get some help from you later if I stuck again ^-^
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 ☺
0
Sure, me, and I'm sure the others, will be happy to help.