4 ms·
Again, that's stupidly easy. Right is bigger, left is smaller. If the current node is a leaf, insert left if smaller and right if bigger. If not a leaf nods,
by maximus-decimus 5y ago
Again, that's stupidly easy. Right is bigger, left is smaller.
If the current node is a leaf, insert left if smaller and right if bigger.
If not a leaf nods, run the method recursively on the left it it's smaller, on the right if it's bigger.
If they asked you to write a self-balancing binary tree it's one thing, but there's nothing tricky about writing a normal ordered binary tree.