You are on page 1of 3

QuickSorti

saDivi
deandConqueral
gor
it
hm.I
tpicksanelementaspi
votandpartit
ionst
he
gi
venar r
ayaroundt
hepickedpi
vot
.Ther
earemanydiff
erentv
ersi
onsofQuicksor
tthatpi
ck
pi
votindif
fer
entway
s.

MergeSorti
saDi v
ideandConqueral
gor
it
hm.Itdi
vi
desi
nputar
rayi
ntwo
hal
ves,
call
sit
sel
ffort
hetwohal
vesandthenmergest
het
wosor
ted

observedthatoutofall sort
ingalgor
it
hmsi fr
unti
mewas
consideredIt
erativ
eMer geSor twast heworstf
oll
owedbyRecursi
ve
MergeSor t.WhilebothQuickSor tswereverycl
oseinrunt
imeRecursi
ve
wascl earl
yfasterforl
argeinputsizes.
TheTabl
ebel
owgi
vest
ime(
s)t
akenbyeachsor
tforv
aluesofn:

Sort 10 100 1000 10000 100000


n
Mer ge ( 0.
0 0.
0 0.
00399 0.
6010 0.
90632
Rec)
Mer ge ( 0.
0 0.
0 0.
0050 0.
7820 1.
5223
I
tter)
Quick ( 0.0 0.
0 0.
00200 0.
3609 0.
48909
Rec)
Qui
ck ( 0.
0 0.
0 0.
0020 0.
3410 0.
5308
I
tt
er)

Comput
ingt
heMemor
ytakenf
orn=10000

Tot
alMemory
used(
MB) Act
ual
Memor
yused(
MB)
I
nit
ial
Bef
oreSor
t 73.
98 0
Mer
geSor
t(Recur
siv
e) 73.
98 73.
98
Qui
ckSor
t(Recur
siv
e) 73.
96 0.
002

Qui
ckSor
t(I
ter
ati
ve) 73.
97 0.
001
Merge
Sor
t (
It
erat
ive) 73.
98 0.
001

You might also like