Complexiy analyss o Random2eol Qulkst
in putcuety A ,01, 3,Y
and Xi be the indioatov rando m va viabl
Pndicofinm
whethe tuo elements Ni &nj ale (omna oY not
The question f's to detevmin the numbeY of counts
agiven i j be
Compred
Cx] "2 Xij
i c j it
Corpovsom of &i wowld happen mly und e he
followin two Comd iti onS
A sub prmblem ol quick sov Comtuns mi &
j
h e nj m Yj is chosen asa pivot
Pivot elemed
Xij tomrav Son
o otherwise
S P T Cni is comfaved j )
ijit
is compaeod to nj]
f rP y i
is chosen
chosen as a
pivot Jt PrLj
Pr i is
as a pvot
tcon be obsevvecl hothe pivot is thosen hom o SG
whch has J-ltL elaments. Tn adolition both the evens
aNe equally ikely
1his 'mplieo that 2-04 3
2
i s ompoveol to j] 1-L
J-it
Jn other tods,the pw bobilih nii L is: 2
j-i+1
J-14T
Substituhon of i-i -k
2 L
onlog n)
Reca
hadis a hormonic Semeo hose thme
soClo n) .
Thercfore the epected (omplenity
runme oF
T0ndomne quict Soat fs o(n log n)