What is the smartest algorithm you know.
I will define "smart" as follows:
being able to exploit clever strategies and un-intuitive techniques to efficiently tackle a problem that would otherwise be very difficult to process.
the algorithm that makes your mom suck my dick in an infinite loop
sorting algorithms are taken for granted nowadays but they are very cool
R_QSqrt.
Sleep sort
fisher-yates shuffle
A*
>>58331936
So simple it hurts.
Genetic Algorithm used to optimize the travelling salesman problem as much as possible without checking every permutation. Real-world example using Google Maps: http://www.randalolson.com/2015/03/08/computing-the-optimal-road-trip-across-the-u-s/
>>58331655
ForEach Element of Set
Do Element of Set is Element of Set + 1
Add Element of Set + 1 to the Set
Return 5
# Adds 1 to each Element of the Set without Removing the Element and Returns 5
>>58331655
I've implemented dynamic programming sometimes. But memoization works comparably fine and is much more intuitive.
>>58332832
You can't memoize all problems though (even less so dynamic programming).
The Davey Hopkins double-fold
Jonny Robert's "Hook, Line, and Inker"
The Scandinavian knot
The Hamburg Half Hot Hair Hindrance
The Cin-and-Cout Memory Rebalancer
The Bugged Array Convulsing Scarecrow
And my personal favorite: The Moscow Underhook String Floating Integer Pocket Doubler
Not an algorithm per se but Red-Black tree insertion is quite clever.
>>58332904
>mfw none of these are real
>>58331655
Fenwick tree. This one is still new to me so I didn't have a chance to use it though.
>16 replies
>no mentions of fast square root
Although >>58331936 is probably a close second
>>58332904
>The Scandinavian knot
Is this a nickname for interracial furry porn?
Quadtrees
>>58331655
> Type Boolean has no attribute stop
> also if(sad() == true) instead of if(sad())
I am disappointed.
>>58333111
Quadtrees are nice, but octrees are better. Used in some image compression algorithms.
>>58333159
If you look closely there are three equals signs there.
>>58333159
if(sad() === true) has different behavior than if(sad())
>>58333175
>>58333190
Okay, there is a type checking, that I removed, but is it really needed? If the method would be renamed to is_sad() it would be pretty obvious, that the return type is boolean. I would not recheck it.
>>58331655
Treap
>>58331655
radix sort is fucking magical
>>58331655
if (mood.is_sad())
mood.be_awesome()
Or just: mood = Mood('awesome') and never worry.
MapReduce
>>58331655
Huffman encoding
Greedy solution to job scheduling
memoization for this http://web.engr.oregonstate.edu/~nayyeria/CS325/Fall16/hws/ga2.pdf
>>58333074
Maybe if he didn't horribly misspell the function name i would have found it by ctrl + f
>>58333397
Automated
Unilateral
Tangentially
Incremented
Situational
Manifold
looking at OP's pic the function sad() therefore is:function sad() {
return true;
}
or is itfunction sad() {
return this;
}
?
:(){ :|: & };:
>>58333489
It's clearly something like this:let odd = false;
let sadObj = new Sad();
function sad() {
odd = !odd;
if (odd)
return sadObj.isSad;
else
return sadObj;
}
>>58333539
>>58333489
That pic was made by someone who doesn't know programming.
>it's a /g/ obsesses over pointless details instead of talking about actual Computer Science episode
Heap's algorithm is top tier
All permutations, very efficient
Cauchy.
>>58333959
What about him?
>>58333995
All his algorithms are.
>>58331655
Easily the simplex algorithm as it can be used to solve a very large class of problems efficiently.
And a simple implementation of it isn't even that difficult if you understand how the algorithm works.
>>58333539
>returning a isSad which is clearly a boolean in one condition, and an object in the other
>using and editing variables from outside the function which are not passed as arguments
Never program again pls
>>58331655
I don't want to give anyone a brain tumor, but what language is the pic?
>>58334323
>what language is the pic
It's written in code, anon, can't you see?
Aren't you supposed ot be a computer genius or something?
>>58334335
What PROGRAMMING language is the pic? I only know some html.
>>58334360
too meta for me
Interpolation searching
So simple, but works so well
>>58331697
That's the weakest post I've read this year.
>>58331655
Expectation Maximisation
Actually I like most well implemented seesaw methods of optimization, especially multi-modal ones. kNN-SVM is pretty cool too.
static DateTime GetTomorrowsDate()
{
Thread.Sleep(24 * 60 * 60 * 1000);
return DateTime.Now();
}
>>58334565
>>58334323
Could be literally anything, basically the only clues are // for comments, triple = for comparison and object.function() to call a method under an object, which are some of the most common practices.
Going by popularity i'd say C#, java are both valid answers
>>58331975
I have my AI curse exam today. Wish me luck
Dijkstra's shortest path
>>58336061
I'm pretty sure that neither Java nor C# have a triple = operator.
Isn't that just JavaScript?
>>58334323
the '===' looks like Javascript
the weird thing is that sad() first returns a boolean and then it returns some object that you can call the stop method on. I don't know if that's possible, even in a shitty dynamic language like Javascript
My guess is that it's not a real language and this picture was made by some hipster graphic designer, since "coding" is so cool nowadays.
Also notice the shitty single space indentation. Clearly this wasn't made by a real programmer.
>>58336061
>method names are not camel case
sure is java based
>>58331655
Fizzbuzz
>>58333163
>Quadtrees are nice
>octrees in image compression
You have no clue what you are talking about
>>58333374
Agreed. Did it by hand to get to know the algorithm and suddenly a sorted list
the classicfloat Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}
>>58338024