Recently I have been working on an idea of mine. My thought process goes that binary search trees are so effective because comparison operators are themselves binary. So, if I were to overload a comparison operator to return 0-3, a search tree with four children would be more efficient.
To explain, say I overloaded a basic integer class's comparison operators to return:
0 if a is <50% smaller than b
1 if a is <=100% smaller than b
2 if a is >50% larger than b
3 if a is >100% larger than b
I'm assuming this has been done before but I can't find any information about it as I have no idea what it's called.
Any insight would be helpful. I have a BST set up and just started implementing the 'N-Tree' (N being the possible return values of the comparison operator) but, frankly, it's getting quite convoluted and I would rather read about this than code it (I'm lazy, I know...).
@JLBorges
Thank you! That is similar to what I was thinking of however I don't see anything regarding the overloaded comparison operators. I'll keep searching though! If I find nothing I'll at least have something to do until school starts =P
@closed account 5a8Ym39o6
Apologies if this came across as a 'homework question' or me asking for someone to implement what I was thinking of, it certainly wasn't that. I just thought that someone had probably already studied/implemented something similar; but without knowing what it was called I didn't really have a starting point to research.
> I don't see anything regarding the overloaded comparison operators.
With that comparison operator determining the placement of a child item, it would be difficult (and computationally expensive) to maintain the search tree in a reasonably balanced state.