7 ms·
> There are problems for which deterministic exact sublinear time algorithms are known. I can imagine silly examples (like "find the minimum element in this li
by dataflow 2y ago
> There are problems for which deterministic exact sublinear time algorithms are known.
I can imagine silly examples (like "find the minimum element in this list under the assumption that no more than O(sqrt(n)) elements exceed the minimum"...), but what's an interesting example of this?
- gleenn 2y agoAnything probabilistic? There are so many interesting fields where you can assume the distribution of a dataset and the take a sample of data and assert things about it with a high degree of confidence. All of modern AI is built on so much of this. All the Deep Neural Nets are making grand assumptions about the shape of meaning of data, they literally assume convexity of the space and they have clearly very interesting results despite the imprecision of the model. Anything dealing with finance is also dealing in lack of data. So if you had a list of prices of a stock over time, you could probably start making assumptions exactly like that, tgat the probability that it doubles over a short time is so unlikely so you can subsample the data and have it still be super useful to make assumptions exactly, especially when you have intractably large data.
- dataflow 2y ago>> deterministic exact > Anything probabilistic? Are you sure you're answering the same question I'm asking?
- _jab 2y agoBinary search is the obvious example. What it and your example have in common is that a significant constraint exists on the input. I can't imagine how a deterministic algorithm with unconstrained input can process that input in sublinear time, but I would love to learn otherwise.
- dataflow 2y agoI can't imagine that's what they meant? The text very specifically says: "Indeed, it is hard to imagine doing much better than that, since for any nontrivial problem, it would seem that an algorithm must consider all of the input in order to make a decision." For them to be thinking of binary search, they would have to be effectively saying "it is hard to think of binary search", which would be a rather absurd position from a CS professor, especially given binary search is quite literally the first algorithm every programmer learns. So I took it to mean there's something interesting here where the inputs could literally be anything, not heavily constrained. But I can't imagine what that might be.
- kadoban 2y ago> especially given binary search is quite literally the first algorithm every programmer learns. I get what you're saying, and it doesn't change your point, but: no _way_ is binary search the first algorithm people learn. For binary search to even be intelligible you already have to know, at a minumum linear search and the concept of sorting (you probably know a sorting algorithm first). You also learn dozens of other really simple algorithms first in practice.
- bee_rider 2y agoAgreed, WRT the bigger picture; lots of little algorithms could come before binary search. But, giving them binary search before sorting kinda works. It is motivating. If you do sorting first, it just seems like a weird high-effort excursion into a niche bookkeeping thing about lists. Once they see how fast binary search is (just give them pre-sorted lists to run it on), sorting becomes interesting, right?
- kadoban 2y agoYeah, it does work as something you learn with/right-before/right-after a sorting algorithm, depending on the teaching style.
- linguae 2y agoThis is what I do in my introductory data structures and algorithms course at a Bay Area community college: I teach binary search as part of my introduction to recursion, and then the following lectures are a series of lessons on sorting algorithms, beginning with selection sort and then insertion sort. After teaching these O(n^2) algorithms, I spend a lecture on merge sort and then have a lecture on quicksort, both for covering O(n lg n) sorts and for introducing my students to divide-and-conquer recursive algorithms.
- bee_rider 2y agoIt is a shame that quicksort has to be covered. I mean, it does have to be covered. But it has an O(n^2) cost for a particular input, despite being generally considered nlog(n), seems to me to introduce some fuzziness in an otherwise solid concept. But it does need to be covered. Unfortunately. (Mergesort is best).
- spoaceman7777 2y agoI mean, yeah, binary search is sublinear, but the data has to be ordered into a binary search tree to be able to use it, which has a much more familiar (non-sub-linear) runtime. I have to assume the reason for the article wasn't to talk about the runtime of algorithms that operate on data that's already in a partially solved state.
- karparov 2y agoAnother obvious example: What's the mean of an unsorted list of integers? If you do a random sample of sqrt(n) values and mean over that, you guess is with high probability pretty good. Or a log(n) sample. (That's how election polling works too which uses even a O(1) sample though not random.) Edit: Ah, GP asked for deterministic exact.
- deleted 2y ago[deleted]
- amelius 2y agoWhat if one if the integers is significantly larger than the rest?
- Aurornis 2y agoBinary search requires a sorted input, which requires that you first consider all elements of the input data set. The sublinear algorithms this page is discussing require that the algorithm not consider all elements of the data set and you're not allowed to pre-process it with an O(n) or greater algorithm. So no trees, no binary search. It's a different set of algorithms.
- tbrownaw 2y agoPublic opinion polling is sub-linear in the size of the population.
- dataflow 2y ago> Public opinion polling is sub-linear in the size of the population. How is public opinion polling deterministic and exact?
- wellow 2y agoLempel-Ziv compression is a good example: https://arxiv.org/abs/2409.12146 https://arxiv.org/abs/2409.12146
- latency-guy2 2y agoI wouldn't call that example silly IMO. I'd consider all the varieties of B-Tree to be real example, which goes to any DBMS. You can extend this out to any direction you want like logging for concrete examples. GIS/Mapping/computer vision has tons of algorithms and data structures that all needed to do better than linear time as well. Stream processing in general is another, but that ends up being probabilistic more often than not, so weak punt into that direction. If you expand the use case out to sublinear space as well, I'd argue for compression of all kinds.
- z2210558 2y agoAssuming shuffled list: estimate of mean, estimate of cardinality etc etc
- munchler 2y agoI think any sort of estimation is ruled out by the word “exact”.
- qyph 2y agohttps://en.wikipedia.org/wiki/AKS_primality_test https://en.wikipedia.org/wiki/AKS_primality_test though it's number theory, and concerned with numbers of size n, rather than lists of length n. Also relevant: https://www.cs.yale.edu/homes/aspnes/pinewiki/Derandomization.html https://www.cs.yale.edu/homes/aspnes/pinewiki/Derandomizatio...
- dataflow 2y ago> https://en.wikipedia.org/wiki/AKS_primality_test https://en.wikipedia.org/wiki/AKS_primality_test though it's number theory, and concerned with numbers of size n, rather than lists of length n. They were talking about not reading a lot of the input, so that's not it.
- Ar-Curunir 2y agoAKS is not sublinear. It runs in poly(n) time, where n is the number of bits in the input (i.e. input size).
- alok-g 2y agoFor that case, a better 'n' to use could be the number of digits in the number.
- minutillo 2y agohttps://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-sea...
- dataflow 2y agoIsn't that O(mn) worst-case run time?
- quuxplusone 2y agoNo, it's O(n) worst case. (The Wikipedia sidebar says "O(mn)," but that's apparently for a maimed version of the algorithm without a key part they're calling "the Galil rule." That's a special usage of the phrase "worst case"! In the absolute worst case, your implementation could have a bug and never terminate at all!) Anyway, the point is that it's O(n/m) in the usual case. Which remains technically linear, not sub-linear; but at least it's O(n) with a constant factor smaller than 1.
- dataflow 2y ago> No, it's O(n) worst case. (The Wikipedia sidebar says "O(mn)," but that's apparently for a maimed version of the algorithm without a key part they're calling "the Galil rule.") It's not "maimed", it's literally the original algorithm. And what the article was specifically analyzing. And exactly what the parent was citing. "No" here makes no sense, unless your goal was just to write "no" to someone on the internet. > That's a special usage of the phrase "worst case"! In the absolute worst case, your implementation could have a bug and never terminate at all! Wikipedia is describing that algorithm, not a different broken one. If your code is buggy then you're not implementing that algorithm, you're implementing a different one that happens to be buggy. It's completely absurd to suggest "the absolute worst case" of an algorithm could include that of a different algorithm. Whether the latter is correct or buggy. > Anyway, the point is that it's O(n/m) in the usual case. Sure, and the halting problem is O(1) in the best case. > Which remains technically linear, not sub-linear So it's neither an example of what the page was talking about (sublinear) nor an answer to my question (interesting sublinear). > but at least it's O(n) with a constant factor smaller than 1. If "usually only reads a fraction of the input" was what I was looking for, I would've realized String.indexOf(char) or Array.find(element) is an answer, and not needed to ask a question here.
- BugsJustFindMe 2y agoConsider that you often need to decide when to stop looking at data before making a decision using what you've seen so far. https://en.wikipedia.org/wiki/Optimal_stopping https://en.wikipedia.org/wiki/Optimal_stopping
- dataflow 2y agoCool as that is, I don't think that's a "deterministic exact sublinear time algorithm".
- BugsJustFindMe 2y agoYou're probably right. Apologies. I think I misread the question initially.
- ssivark 2y agoThink from an information theory perspective. It is rarely true that you cannot say anything more about the data than what is assumed by classical algorithms. We almost always have some more information depending on the specific domain under consideration. Eg: Sorting a list of ages might be very different from sorting a list of account balances. Any time I have information that reduces the entropy of the dataset, I want to be able to leverage that into runtime improvements of algorithms for pertinent questions. And it would be great to develop a structured framework for that instead of handling special cases in an ad-hoc manner.
- ssivark 2y agoAs one example of such a more general framework -- (variants of) belief propagation might be a good answer if dataset constraints could be cleanly formulated as distributions to be reasoned with.
- oxavier 2y agoMy work is about inferring solutions to Constraint Satisfaction Problem by using belief propagation in the corresponding constraint network, a few keywords caught my eye here :) Do you have any illustrative example so I can understand better what you are hinting at? Cheers
- an_ko 2y agoFully dynamic connectivity on general graphs comes to mind. https://en.m.wikipedia.org/wiki/Dynamic_connectivity https://en.m.wikipedia.org/wiki/Dynamic_connectivity (Graphs, with operations to connect and disconnect nodes, and to check whether two nodes are connected by some path.) State of the art there is poly-logarithmic time worst case.
- JonChesterfield 2y agoData structured as trees permit a lot of sublinear operations. Set intersection for example, you traverse the two trees in the same order, and where a node exists in one and not the other, you know nothing under it is in the intersection.
- Aurornis 2y agoIn this case, Sublinear Algorithms refers to algorithms that don't consider the entire input set. A B-Tree would not qualify because it must first consider the entire input set. Only later operations can be less than O(n) because you've already done O(n) or greater work on the data set.
- indoordin0saur 2y agoI'm surprised this is even a debate on HN. Aren't we mostly computer scientists here? Several examples on wikipedia: https://en.wikipedia.org/wiki/Big_O_notation#Orders_of_common_functions https://en.wikipedia.org/wiki/Big_O_notation#Orders_of_commo...
- deycallmeajay 2y agoWhat about GWP-ASan? It basically samples a portion of allocations with ASan looking for memory corruption bugs. If your app is used enough it’ll find the bugs eventually without the performance overhead. https://llvm.org/docs/GwpAsan.html https://llvm.org/docs/GwpAsan.html
- ice-water 2y agoA round-robin tournament with n players, where you have the results (win/lose) of all the games and you must determine whether there is a player who won all his games. The input is the n(n-1)/2 bits indicating the results, but the existence of a winner can be determined in O(n) steps (fun exercise).