Rahul S. answered 05/19/25
Senior Software Engineer
- If you expect both many inserts and many selections:
Use the balanced tree. It keeps things efficient for both tasks.
- If you expect many inserts but very few selects:
Keep things simple by storing data in a list and find elements when needed with a selection algorithm.
- If you expect many selects but very few inserts:
Sort once and then quickly pick elements by their position. Insertions are rare, so it’s okay if they take longer.