Hacker News new | past | comments | ask | show | jobs | submit login

It probably depends how artificial you allow your problems to be. In competitive programming, range queries are quite common because they're easy to specify and there's a variety of techniques and data structures for them, and they combine well with other techniques. For example, there are segment trees, sqrt decomposition, fenwick trees, cartesian trees, cumulative sum arrays, and certainly more that I'm not thinking of. And for each they can be used in combinations, like a segment tree full of tries, or using most to help answer "lowest common ancestor" on a tree.

So in competitive programming the quoted text is certainly true.

In day-to-day work the allowed operations just don't tend to come up. Where they do, there usually seems to be a natural block size you can use instead. Like if I wanted to know the least amount of sleep per day I've gotten in a period of time, I'm probably going to want to know per week/month/year, and it's easier to just have a table for each "scale" that I update once per data point.

That, and most of the time the data points I'd want to mess with would be in a SQL database and it just doesn't make sense to use anything the DB doesn't provide itself unless it's very important in the business context.




Thanks for the detailed answer, and I do understand that the average programmer isn't going to reach for an esoteric algorithm to solve their day-to-day problems.

But what about their usefulness in operating systems or libraries? Or the SQL database you mention -- could it maybe make use of such datastructures?




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: