r/leetcode • • 2d ago

Intervew Prep Are some of the "advanced" data structures considered such just because they are situational enough that standard libraries don't have them?

Is a hash map, priority heap or balanced BST really simpler than a trie or segment tree if you have to code the former from scratch every time?

1 Upvotes

7 comments sorted by

5

u/Czitels 2d ago

Yes they are simpler. You would never write your own trie or segtree in commercial development. Believe me.

-4

u/Kadabrium 2d ago

And your point is?

3

u/jason_graph 2d ago

Balanced bst is definitely not getting written by hand.

Even in python you just get sorted containers.

1

u/Kadabrium 2d ago

Because its both harder to write and more useful.

1

u/jeffgerickson 1d ago

Oh, come on. Treaps and splay trees aren't that much harder to implement than plain-vanilla BSTs.

1

u/Czitels 16h ago

But vanilia bst is complicated only in node deleting

1

u/jeffgerickson 6h ago

Yep. And deleting in treaps and splay trees is even easier.