2 ms·
There’s more than making a node the points to other nodes. That’s not what makes a binary tree a binary tree.
by jb1991 5y ago
There’s more than making a node the points to other nodes. That’s not what makes a binary tree a binary tree.
- nostrebored 5y agoI mean… it literally is all there is to it
- jb1991 5y agoWell, the requirements I faced were to implement the tree such that nodes were inserted with the standard ordering you would expect. Walking the tree to find the best place to insert them, etc.
- maximus-decimus 5y agoAgain, 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.