Why? The only time I knowingly used them is with database indices. For everything else I do, they are an unnecessary implementation detail. It doesn't matter what Ruby's Set uses.
If you really can't, you should get familiar with how data can point to other data, it is fundamental and done all the time.
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.
[data, *next] [data, *next] [data, *next] [data, *next]
If next is null (0), it's the end of the list.It's easy to make an imbalanced binary tree.
I once decided that building a binary tree based only on a friend's explanation of how they worked; it seemed like it would be a good learning exercise for myself (I don't have a CS degree). It was like 10 minutes of coding to get it minimally working & tested, but then I had to work out all of the different rotations to make it a balanced binary tree (I don't know that an imbalanced binary tree is ever actually useful, as it could just work out to be a slower linked-list in the worst case scenario).
I did it once, took me a little while, but I don't know that I could do it again without having to reexamine all of the different cases that result in imbalance and the rotations that respond to each.
If you audition for the New York City ballet, they don’t expect you to ice skate.
For example I think writing some logic to filter datapoints or timespans is much better and more practical. But it takes more effort than just opening and pocking binary tree.
I wouldn't want to have an interview with you, or you selecting people for a team I'm on.
People in general do not communicate on the cleanest ambiguosity-free way;
I’ve interviewed a _lot_ of people. The people who gripe the loudest about algorithms haven’t had a chance just from answers to situational questions.
Nobody talked about implementing a specific variant of a red-black tree when the general topic of self-balancing binary search tree hasn't even be mentioned.
So depending on the actual exercise/interview question you might able to just show that, especially of you have to use pseudo code.
The self-balancing part is usually added after the search part as balance is trivial/unimportant when the order/position of the elements has no constraints.
I imagine there's quite a lot of them. Things like VP-trees and such get often built statically and could be implemented in a similar way. Not sure if the simple (2i, 2i+1) schema is optimal for this but perhaps it could be adapted.
That said, for most dev jobs implementing a binary tree isn't necessary knowledge. But if I need a dev who can get their hands dirty I would be weary of hiring someone who can't take a decent stab at it during an interview.