Skip Navigation

I have a problem creating trees

I was trying to creating a red-black tree, and when trying to get data out of it, it always returned the same value, so i decided to try to create a very simple binary search tree, and i got the same result, so i wonder, ¿what i'm doing wrong when trying to create trees in c++? Here is the code: https://pastebin.com/L2yJJ3Nu

8

You're viewing a single thread.

8 comments
  • Your get() function will always just return the value of the root node. I think you mean to have return get(value, ...) in each of its if statements.

    • it worked, thank you :D

      • Nice, good luck with it from here!

        • i managed to do it (or thats what i think), the tree apparently works, but i dont know if its balanced, can you have a look at my code? i want to know if my tree is balanced correctly, here is the code: https://pastebin.com/ineG07b2 (PS: im aware that this code doesnt guarantee that the root will be black, the wikipedia article says that the black root is not a strict requirement by all the authors, so i decided to omit that)

You've viewed 8 comments.