Ask HN: What is new in algorithms and data structures these days?
737 pointsAlgs/DS were my first love in CS. Nowadays, all we hear about is AI/ML. There must be hardware/software improvements coming from or necessitating fundamental Algs/DS research.
Care to share any of the favorite recent results?
Are there big fields still making gains behind all this computing surge?
Comments (211) 45 threads
Earlier commentshttps://web.stanford.edu/class/cs168/index.html
I didn't have time to go through all of this, but the parts that I did read were very interesting to me.
It's not even cutting edge new stuff of 202x, probably most of them are new-ish results from ~2000 onwards.
- Eventual consistency [2]
- Refinement types [3], [4]
[1] https://www2.cs.uh.edu/~ceick/6340/Streams.pdf
[2] https://www.microsoft.com/en-us/research/wp-content/uploads/...
[3] https://ranjitjhala.github.io/static/trust_but_verify.pdf
[4] https://ranjitjhala.github.io/static/refinement_types_for_ty...
Indeed. To me, they look like a formalized subset of precondition contracts that can be checked statically. I don't think the idea is new, I seem to recall Ada and Eiffel having something like this, but I first learned about them via Racket[1]. I still don't know how they work or what's needed to implement them.
but from what I know no static analysis is done on the refinement/"where" part, it's a runtime assertion only.Interestingly, Raku has a similar concept called `subset`, eg.
[1] https://blog.racket-lang.org/2017/11/adding-refinement-types...
Why make it more complicated? :-)
The secret is that given values are smartmatched against the given object. And the values 1 through 10 will return True if smartmatched against the 1..10 Range object. The `of Int' ensures that only integer values are allowed, otherwise 3.14 would also match. Unless of course, that is what you intended. In which case you can omit the "of Int".
Continue this thread — 1 reply
I believe it's because they're not exactly easy to implement and the resulting extensive type checking might also affect compiler performance.
By the way, another great example of refinement types (in JavaScript) is this one: https://kaleidawave.github.io/posts/introducing-ezno/
What I mean is: in the comparison model, assume start with an empty heap, a sequence of instructions like "insert element x" and "remove minimum element" of length n.
There's an algorithm that can tell you in O(n) time, which items are still left in the heap at the end (and thus also which items have been removed at some point in time).
The algorithm can't tell you exactly _when_ items have been removed, because that would be equivalent to sorting, and you need at least O(n log n) to sort in the comparison model.
I've worked on this problem on and off for about a decade now as a little hobby project. I would have been happy to prove it impossible or to find a solution. Interestingly, it is possible and the solution is relatively simple, too.
(I have no clue whether this is useful for anything. In practice you probably just run the obvious O(n log n) algorithm which probably has much better constant factors. I'm doing this purely for the theory.)
The data structure / algorithm I found is expressible in a purely functional setting, and (spoiler alert) builds on top of Chazelle's Soft Heap.
But this reduction from 'select n largest' to my problem is still instructive: it tells us that in some sense any (deterministic) solution to my pet problem has to be at least as complicated as (deterministic) median finding.
As the sibling comment points out, that's not news. But it's very good for you to pick up that implication from first principles alone. It's part of figuring out how to solve this.
If I find someone else who's interested enough in my pet problem to go to the hassle of scooping me, I'd be elated.
https://arxiv.org/pdf/2201.09331.pdf
All comments shown.
Couldn't load more comments. Check your connection and try again.