
Speeding up the charting of sensor information as a waveform graph - wuschelhase
https://www.kdab.com/a-speed-up-for-charting-on-embedded/
======
kadoban
The data structure invented here is called a "segment tree" in competitive
programming.

It's absurdly common in that context and fairly esoteric anywhere else.
[https://cp-algorithms.com/data_structures/segment_tree.html](https://cp-
algorithms.com/data_structures/segment_tree.html) is one presentation of it.

~~~
pmoriarty
_" In general a Segment Tree is a very flexible data structure, and a huge
number of problems can be solved with it."_

If they're so flexible and useful, I wonder why they aren't used more
frequently.

~~~
kadoban
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.

~~~
pmoriarty
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?

------
jerrre
Title is slightly misleading (the shortened version of this post even more).
Together with the fact that min-max is very similar to minimax[1] it made me
expect an (language) AI article

The article is mostly about optimizing a specific function/data structure for
fast displaying of waveforms (still interesting :]).

[1]
[https://en.wikipedia.org/wiki/Minimax](https://en.wikipedia.org/wiki/Minimax)

~~~
dang
OK, we've changed the title to something more representative of the article.
If anyone can suggest a better (more accurate and neutral) title, we can
change it again.

