MongoDB Interview Question

How do you balance a binary tree without using a self-balancing algorithm like the ones Red-Black Trees and AVL trees use?

Interview Answers

Anonymous

May 29, 2018

The key is uniform distribution and random insertion. I need to ensure that field to be indexed in btree has high-cardinality and data not growth monotonically. For example: SKU (stock keeping unit) has high-cardinality and random growth, but timestamp only has high-cardinality.

Anonymous

Nov 5, 2018

Splay tree is a good example . Kinda like recently used cache. Recently used elems are near the root (or root) Maybe they were waiting for B/B++-tree. Since it's a self-balanced Tree (not binary though) which is used in DBMSs