Professional Documents
Culture Documents
Note May 7, 2023
Note May 7, 2023
Aces scornmetperse
yetget get pere
Army ON ON ON ON ON ON ON ON
Stuck ON OLN 04 OC O N O N Oct On LIFO addFirst tremorsFirst
QueueOld Oln On 0111 ON OINI O 1 On FIFO addLastremoveFirst
Split intoitems
2 pint and spirit
6 1 4,5132 7,87 Lsplace pivot divide
Hoare
6 1 4,5 3 I 7 g 1 left mover till finds els pint
I 4,5 3 I 7 g
2 then right moves till fails ele pint
3 swap if ours thenpart issorted
Random is faster than med since it's hard to compute
selection
pint
a Worst care pivot extremes11 all items equal
a Quirksent his faster overall runtimeand memory usage
than Merges
we use a linear med finding algo then OlNdey
N
AM
MergeSat O NlogNfastest stable comparison sort
a Fach merge GCN merge halves by comparing their
el until individual dis which are
first we're just merging suited
if we had a sect where we run insertion suet once the
runs are
of size 4100 The runtime for merge op's
becomes constant s need exactly
log 100 O N O IN
temp Sert Ol NbyN Iunstable may compare same
el's twin
1 in rev Level order find max child of this nude thenswap if
this node is less Bubble downrecursively
2 removeSagest Ily I and swap wt last unsorted item in array
bubble to right spot
a minHeap is empirically a little worse we'll still add
items to the end then reverse in a diner pass