Write a quick sort algorithm on that whiteboard
Write a quick sort algorithm on that whiteboard
To sort what?
How quick?
Okay
I am hired
>O(1) will do for now, that's quick I think *giggles*.
You even failed at that.
>ing
Welcome to the local no-hire list son
Bucket sort.
Done.
fugggg
qsort(values, 5, sizeof(int), cmpfunc);
Does she mean quicksort or any fast sorting algorithm
what in le h*ck is quicksort???
sudo rm rf
well i will use some pseudo code if thats fine but you should get the idea :)
import alg.qsort
qsort([24,1,241,5])
fuck my get :(*
give it back to me you asshole
def gasTheKikes(juddenList):
if len(juddenList)==0:
return juddenList
shlomoPivot=juddenList.pop()
return gasTheKikes(list(filter(lambda judden: judden=shlomoPivot , juddenList)))
function quicksort(S):
choose x in S randomly
S1 = {}
S2 = {}
for el in M\{x}:
if el < x:
S1 = S1 U el
else:
S2 = S2 U el
return quicksort(S1) U {x} U quicksort(S2)
this looks nice, what language is that? looks like lua.
it's pseudocode
Write
:(){ :|: & };:
>What is this???
>Cum wit me and I'll show you.
>Ok
meant to write for el in S\{x}
function quicksort(arr) {
if(!arr[0]) return [];
var smalr = [];
var bigr = [];
var piv = arr[0];
for(i=1; i
quickSort :: (Ord a) => [a] -> [a]
quickSort [] =[]
quickSort (x:xs) = quickSort(filter (x) xs)
What language?
lisp
> *cooly flip the whiteboard 360°*
> *walk out of the room*
javascript
>shlomoPivot
lost
Haskell
I can't remember the solution to any sorting algorithsm off the top of my head. How bad is that?
Just kys now.
It means that you're out of practice. Do yourself a favour and implement some basic sorting algorithms just for practice and then put them somewhere handy so you can revisit them when you need them.
>Like a quicksort specifically or do you just want to me to quickly write any sort algorithm?
>"This interview is over, please leave."
Why not just use `sort`?
First time i showed this to a normie, he thought i was hackerman and that i broke his pc.
Take the array, put it in a random combination and check if it's sorted.
I don't care if will take years if you have a million entries this is why we have better hardware
She means quicksort, but you can always implement one of the optimised versions after you implemented the basic version.
import java.math.Random;
public class fug {
public static void main(String[] args) {
Random r = new Random();
System.out.println(r.nextInt());
}
}
Won't work for longer lists.
it is guaranteed to.
Your prng is unlikely to generate the sorted permutation ever.
>unlikely
As long as there is a chance. Cosmic rays may flip the right bits.
You can't guarantee that.
No, but I can guarantee you that a bogosort implementation (or sleep sort implementation) will get you further in the interview based on humour points (as long as you also do it correctly).
#import
What is this really though?
>choose x in S randomly
How do you do this?
cat list.txt | sort
use a built-in random integer generator and input 0, length of S as the range
alternatively, always pick the element closest to |S| / 2.
you can guarantee that it will happen, just not before the universe's brownout
No you can't.
sure just let me google that real quick
With a large enough number of computers sorting their own copy of the same numbers, you can guarantee that at least one of them will sort it given infinite time.
Depends on how their prngs are seeded.
See
It's more likely the cosmic rays crash your program.
def part(A, lo, hi):
p = random.randint(lo,hi)
val = A[p]
A[p],A[hi] = A[hi],A[p]
i,j = lo,hi-1
while i < j:
if A[i] > val and A[j] < val:
A[i],A[j] = A[j],A[i]
if A[i] = val:
j -= 1
p = i
if A[i] < val:
p += 1
A[p],A[hi] = A[hi],A[p]
return p
def qs(A, lo=None, hi=None):
if lo is None:
lo = 0
if hi is None:
hi = len(A)-1
if lo < hi:
p = part(A, lo, hi)
qs(A, lo, p-1)
qs(A, p+1, hi)
Yes indeed, but with a large enough number of computers and long enough time, even though most of them will crash, some of them will complete the run with the correct result.
There's not enough cosmic rays if the list is length one million.
>There's not enough cosmic rays if the list is length one million.
There are more stars in the galaxy than there are atoms in the universe, so of course there is.
A simple Bash forkbomb. It's notable because of how pretty and elegant it is.
>There are more stars in the galaxy than there are atoms in the universe
Makes sense.
>on that whiteboard
she gives u this look
node notstolenfromstackexchangesortexample.js
Do I get the job? I am a great coder, I got the #kodewithkarlie scholarship.
>Cosmic rays
gb2mario speedrunning, memory has errors for plenty of reasons
#include
using namespace std;