by dataflow · 1y ago · 0 comments
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?
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.
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.
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.
Almost every 6-10 year old kid who had to use physical dictionaries intuitively learned (probably even discovered by themselves) something like binary search. It's a different matter whether they could formalize that into an algorithm and write code to handle all the edge cases. But the basic idea is very intuitive. Kids can also pick up the intuition to incorporate improvements even beyond balanced binary search eg. there might be a lot of words starting with "S" so split into two groups at a little less than the middle, etc.
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?
It legit was the first one we learned, the first algorithm written on the blackboard by the professor (this was in the 2000s but the first algorithm lessons were on blackboard and paper!)
Probably because something simpler linear like "find the minimum value in a list" is too dull as an algorithm example
It's an unusually intuitive algorithm, so it wouldn't surprise me if it were one many people learn first.
> there are classical optimization problems whose values can be approximated in sublinear time
This can actually be quite useful if the approximation is guaranteed, or even if it isn't, as long as it works well in practice.
https://www.dcs.warwick.ac.uk/~czumaj/PUBLICATIONS/DRAFTS/Dr...
Searching in sorted lists is the first example, although they acknowledge that "the assumption that the input array is sorted is not natural in typical applications." They then give an non-trivial variant of this problem, where the sorted list is stored as a linked list, so that you cannot directly jump to some element at position i.
Another example for a sublinear algorithm they give is to check whether 2 convex polygons intersect, using the algorithm by Chazelle and Dobkin.
And your first quote is followed by "However, for most natural problems", which further indicates that the known exact algorithms are for trivial problems.
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.
Edit: Ah, GP asked for deterministic exact.
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.
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.
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.
Do you have any illustrative example so I can understand better what you are hinting at?
Cheers
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.
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.
State of the art there is poly-logarithmic time worst case.
> Anything probabilistic?
Are you sure you're answering the same question I'm asking?
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.
Also relevant: https://www.cs.yale.edu/homes/aspnes/pinewiki/Derandomizatio...
They were talking about not reading a lot of the input, so that's not it.
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).
How is public opinion polling deterministic and exact?