r/itsaunixsystem • u/foaly100 • Mar 23 '19
[Arrow] Using an exponential search algorithm to find where a really smart criminal is without any video surveillance
474
u/NyiatiZ Mar 23 '19
Oh, even the worst kind of search algorithm
196
u/b10011 Mar 23 '19
O(n!) is the worst
224
u/ACoderGirl Mar 23 '19
Hey, my "shuffle indefinitely till it is sorted" algorithm has the potential to be extremely fast in very specific circumstances!
89
u/b10011 Mar 23 '19
O(1) time complexity if the array is already in order, it can't be a bad algorithm!
My version is more stable though. It generates all permutations and checks which of them are in ascending or descending order!
38
u/Brotalitarianism Mar 23 '19
To be pedantic, you have to check if it's sorted, so it's still O(n) in the best case
34
u/b10011 Mar 23 '19
I assume the user of my sorting library knows that they need to feed already sorted array into my sorting function.
17
u/xTRS Mar 23 '19
/* Input: SortedArray A * Output: SortedArray */ SortedArray preSort(SortedArray A) { A.isSorted = TRUE; return A; }10
u/b10011 Mar 23 '19
I would prefer checking that the list is in order in the constructor of the SortedArray. That way we can prevent execution any further by throwing some sweet DumbUserMalfunctionExceptions.
5
u/jobblejosh Mar 24 '19
I just assume the array is already sorted, and leave it at that.
Zero-time sort finally implemented!
4
u/Brotalitarianism Mar 23 '19
I'm gonna steal that one next time someone asks me to sort an array
18
u/b10011 Mar 23 '19
Yeah and it's super simple in many languages!
Python: lambda l: l
Javascript: i => i
Haskell: f l = l
C++11: [](type l) -> type { return l; };
Java.. Oh wait, you need AbstractPresortedListOrArrayLambdaInterfaceFactoryWrapper.
3
u/amodump Mar 24 '19
Not to be double pedantic, but that is technically Ω(n)
2
u/Brotalitarianism Mar 24 '19
Always double down on being pedantic- I had completely forgotten about that notation.
3
10
u/NyiatiZ Mar 23 '19
You are totally right, my bad!
9
u/b10011 Mar 23 '19
My reaction when I took a course about these: "Factorial time complexity can't be THAT bad... HOLY FUCK"
6
u/NyiatiZ Mar 23 '19
Imagine nn like „What?“
23
u/b10011 Mar 23 '19
49 items and time complexity is larger than there are atoms in the universe.
8
14
u/tenfingerperson Mar 23 '19
O(nn ) is much worse than n!
18
7
u/b10011 Mar 23 '19
I meant it's worst out of the common ones (I have never seen n^n algorithm (could be that I'm just unsophisticated)), but yeah, technically the worst time complexity is ∞.
5
u/xTRS Mar 23 '19
You'd have to use an On as a check or something...
for(obj i in list x; i.sort(); i.next()){ if(x.isSorted()) { result = success;}}Just kinda off the head, not actually thinking about it
3
u/b10011 Mar 23 '19
Just make .sort() return 0 if successful and that's O(1) algorithm! I don't understand why I have not been given a nobel for my optimization skills.
1
1
u/developedby Mar 24 '19
i don't understand your comment
1
u/NyiatiZ Mar 24 '19
What exactly? I’m always open to explain
1
u/developedby Mar 24 '19
the meaning of the sentence
2
u/NyiatiZ Mar 24 '19
An exponential algorithm is written as O(xn) and takes the 2nd most time of all possible kinds of algorithm. The fastest would be O(1) which always takes the same time, no matter how many objects you would have to look through
1
u/developedby Mar 24 '19
2
u/NyiatiZ Mar 24 '19
Im talking about exponential time consumption, not about an algorithm calles "exponential_search" however the fact that this exists can cause some confusion
1
134
166
57
u/PhDinGent Mar 23 '19
Pfft, not even using a Visual Basic GUI interface. Are they even trying?
22
61
Mar 23 '19
Maybe this was the joke.
I mean only way of finding someone with minimum evidence is using exponential search algorithm probably.
7
24
22
Mar 23 '19
What show has crime solving supermodels?
15
u/DerTrickIstZuAtmen Mar 24 '19 edited Mar 24 '19
If TV taught me anything it is that all female computer specialists look like models during a shooting while being socially inept/awkward at the same time.
12
u/syco777 Mar 23 '19
I just like to think they simply had a sorted array of possible locations to comb through lol
11
17
8
10
4
u/engineeringsquirrel Mar 23 '19
That lady in the back left looks like she's not believing any of her shit.
She's like "really, that's the shit you're going with?"
4
4
3
u/chidoOne707 Mar 23 '19
Oh i missed the latest one? The last one was the logarithm code from the Flash.
2
1
0
-1
Mar 24 '19
If you're going to corrupt an action show into becoming the Felicity Smoke Feminist Power Hour, then at least have the common decency to hire a technical consultant to make her at least sound like she knows what the hell she's talking about. SJWs are the worst.
1
-15
u/Daafda Mar 23 '19
*logarithm
17
u/err_pell Mar 23 '19
No. It's algorithm.
8
-14
u/Daafda Mar 23 '19
*its
3
u/Cole3003 Mar 23 '19
You are wrong again. "It's" is a contraction of "it is," "its" is possessive.
-6
7
u/CapJackStarkness Mar 23 '19
I’m fairly certain this scene someone was asking her to find something and she compared it to an exponential search algorithm.
This show has plenty of better fodder for this sub.