Lurker News
Algs/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 comments
hnfong1 reply#
CS 168: The Modern Algorithmic Toolbox, Spring 2023

https://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.

trebligdivad#
Thanks! That looks great, for those of us who did our algorithm courses too long ago!
NeuroCoder2 replies#
Refinement types are pretty interesting and I've seen mention of them recently. I'm curious if there are any practical reasons we don't see them implemented in more languages.
klibertp1 reply#
> Refinement types are pretty interesting

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.
Interestingly, Raku has a similar concept called `subset`, eg.

    subset OneToTen of Int where * > 0 & * < 10;
but from what I know no static analysis is done on the refinement/"where" part, it's a runtime assertion only.

[1] https://blog.racket-lang.org/2017/11/adding-refinement-types...

lizmat1 reply#
subset OneToTen of Int where 1..10;

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

codethief#
> I'm curious if there are any practical reasons we don't see them implemented in more languages.

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/

eru2 replies#
I'm working on a paper to show that you can 'simulate' a heap in linear time.

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.

cochne2 replies#
Doesn't that imply a linear "n largest" algorithm? I guess that might already exist, but I wasn't aware of that!
kopecs1 reply#
Quickselect and non-randomized variations should get you that; no?
eru#
Yes, exactly.

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.

eru#
Yes, that does imply a linear 'n largest algorithm'. Specifically also linear 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.

ladberg2 replies#
Are you at all worried that by posting an open problem on HN and claiming you've found a simple solution, someone might scoop you to the paper?
bitcoinmoney#
Idea to paper is non trivial effort. Lots of iterations need to be done.
eru#
I'm not a professional academic.

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.

mad#
The Cuckoo Trie, an ordered index data structure explicitly designed to have memory-level parallelism, which out-of-order processors can exploit to execute DRAM accesses in parallel:

https://arxiv.org/pdf/2201.09331.pdf

Load more comments