You are on page 1of 2

Average Worst

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

saggy ON OWI0111 0111 ONI ON OLIOLI

BSToutoutout at OCNOCN 01N 01N a Hibbard replaceitem w smallestitem


greaterthan it
135T For nodeX inthe tree
any
everykey in itsright
subtreeis subtree
Property
in
everykey itleft
lessthan X'skey is greaterthan x's

3Tme All leaves mustbe I distfromsource


A

aFach 2 3 the node must have atmost 2


elements 3 children
toyN
all alnsertion Addtoleafnodeandpush excessitems middle up
AA non deafnode ul Kitems musthaveexactly RH children
IRB a No node can have 2 red links analogous to 4 now
tryN aEverypath fromroot to leaf hasblacklinks red links differ
HI OH0111 ON ONON ON01N a Keys hashcodeshould be
Ilmoetized Runtime is the cost1 deterministic callingmultipletimes
avg
over operations shouldreturn the same value
many
a hashmap that increasesbuckets affects consideredequalshouldreturn
y consistent wt equals
10 when NIMst has an the same codes
ly insertiontime
amortized of N
Eep Insert O logN 1 Everynode is E both children

getSmallest 011 2 Annodes or left as possible


removeSmallest AlleyN is no relationship btwn left right side
the items it shouldbe bottom
a Min Heap Prop 314 heap's missing
any
Constructor GIN A theft1 1 Olmightt logN connecttrees y
way Connect 01N equalsize Htt
cap
is connected o dogn
q QS IN toyN 01N Unstable
Hours 1 Sort 1 d time pivot ideally central ve
once sorted nun looked at again

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

You might also like