3 ms·
It all depends on the specific topic. If I just want to store my data in binary tree structure without the possibility of deletes and just with an insertion-ord
by ascar 5y ago
It all depends on the specific topic. If I just want to store my data in binary tree structure without the possibility of deletes and just with an insertion-order requirement, then the tree is automatically balanced and using an array like that is totally fine. The use-cases are probably rare (I can't think of a situation from the top of my head), but binary tree doesn't have to mean search tree.
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.
- jhgb 5y ago> The use-cases are probably rare (I can't think of a situation from the top of my head) 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.