Hello everyone!
Here I am with another doubt this time considering data structures.
I was given a homework sorta.
To create a binary search tree with the following values.
5, 4, 3 ,1, 17, 8, 11
I'd post a picture but i don't know how so.. the old fashioned way
The given solution is :
root node is 5
root's left-child is 4
it's left child is 3
and it's left child is 1
then the right subtree
root's right-child is 17
it's left child is 8
and it's rigth child is 11
written other way :
left subtree(5->4, 4->3, 3->1 ) right subtree (5->17, 17->8, 8->11)
My Solution differs a bit...
i made it that way :
left subtree(5->4, 4->3, 3->1) right subtree (5->8, 8->11, 11->17)
My question is :
Since both look as being a valid binary trees I can't really see the difference in
these solutions, therefore, my question.. is my solution also a valid solution to
the given problem.
Thanks in advance
What I have tried:
I can see why is the given solution all right but I don't see a valid reason why mine would be wrong,
Is this thinking correct?