What's the slowest non-Bogosort sort you can think of?
For me, it's
- Compute all the n! permutations of the list
- Do a breadth first search of the ordered permutation.
which, if done right, can be O(n*n!logn!).
Instead of the slowest sort possible, try to implement a sort that is as slow as possible while still being reasonably[1] fast.
1. ^ Definition of “reasonable” here is that if you were to implement said sort in a closed-source program distributed for the general public, no one would notice something strange was going on.
Bogosort. Essentially its the equivalent of throwing a deck of cards against a wall, picking them up, and seeing if they're sorted. Runs at O(n!) with no upper bound.
>>14 Runs at O(n!) with no upper bound.
Runs with an upper bound of n! with no upper bound?
Bogosort is O(inf).
Also, Bogosort is not a non-Bogosort sort.
>>16
That's good, except it should first check if the array is sorted already and if it is, unsort it.
To extend the concept, make a program that searches the memory of currently active processes and automatically detects any sorted arrays and messes them up on sight.
Name:
Anonymous2012-07-22 11:20
I see what OP's master plan is here.
#1) Develop top selling product
#2) Wait until the product is on 90% of all usable machines
#3) Release update including the following code:
Add program to startup queue
Disable any functionality allowing users to end the program
Start 20 threads, each doing:
Create int array of size 999,999,999
Sort as slow as possible using what is essentially bogosort.
???
Profit.
Genius.
Name:
Anonymous2012-07-22 12:47
Sleep sort that sleeps for 2n seconds, where n = given number.
>>19
Intel already does that with the Linux kernel to increase CPU sales.
Name:
Anonymous2012-07-22 14:04
>>18
Here, for Python: # heron: make a mess out of your lists
heron = lambda: ((lambda f: f(f, set(), globals(), __import__('random').shuffle))(lambda heron, s, w, shuffle: ([(lambda v: ((s.add(id(v)), heron(heron, s, v, shuffle), shuffle(v) if isinstance(v, list) else None,) if isinstance(v, (dict, list, tuple, set)) and id(v) not in s else None, (s.add(id(v.__dict__)), heron(heron, s, v.__dict__, shuffle),) if getattr(v, '__dict__', None) and id(v.__dict__) not in s else None,))(p) for p in (w.values() if isinstance(w, dict) else w) if isinstance(w, (dict, list, tuple, set))],)), None,)[-1]
Name:
Anonymous2012-07-22 14:04
>>18
Here, for Python: # heron: make a mess out of your lists
heron = lambda: ((lambda f: f(f, set(), globals(), __import__('random').shuffle))(lambda heron, s, w, shuffle: ([(lambda v: ((s.add(id(v)), heron(heron, s, v, shuffle), shuffle(v) if isinstance(v, list) else None,) if isinstance(v, (dict, list, tuple, set)) and id(v) not in s else None, (s.add(id(v.__dict__)), heron(heron, s, v.__dict__, shuffle),) if getattr(v, '__dict__', None) and id(v.__dict__) not in s else None,))(p) for p in (w.values() if isinstance(w, dict) else w) if isinstance(w, (dict, list, tuple, set))],)), None,)[-1]
>>31 Stephen Wolfram's parents were Jewish refugees who emigrated from Westphalia, Germany, to England in 1933.
But you already knew that, kike.
Name:
Anonymous2012-07-24 14:19
Random sort. Try a combination and check if it's right; if not, repeat. It has unpredictable time constraints, and doesn't necessarily generate the correct result, ever. Making it effectively O(inf).
Name:
Anonymous2012-07-24 14:37
public static void bogoSort(ArrayList<String> array){
// OH GOD WHAT HAVE I DONE
boolean sorted = false;
int iter = 0;
while (!sorted){
iter += 1;
System.out.println(iter + ": " + array);
Collections.shuffle(array);
for (int i = 0; i < array.size() - 1; i++){
if (Integer.parseInt(array.get(i)) > Integer.parseInt(array.get(i + 1))){
break;
} else if (i == array.size() - 2){
System.out.println("Solution found! " + array);
System.out.println("Sorted in " + iter + " iterations!");
sorted = true;
}
}
}
}
>>34
You learn basic mathematics, you piece of shit. f(x) ∈ O(g(x)) ~~ ∃k>0,x0.∀x>x0.f(x)<=g(x)*k
Look at the plot I linked. Guess what‽ At exactly x0 = 2, k = 1, for every x larger than x0, log n! is larger than log n. Holy shit!! What will that mean? Maybe that log n ∈ O(log n!) and not the other way around.
That's even written on fucking wikipedia, that's how retarded you can get.