Professional Documents
Culture Documents
Exercise 6
Exercise 6
Question
T.Whenmanykeysareduplicated.ch anging
one of > = or < = +0
> oraresultinaunbalancedrecursiontr.ee
Torexampleasubarraywithidentic.ae elements
7770rigind
andchi-IEII-EI_llin-ionextrecursionp.ro
( < = and > =
) > =
t nextrewsioi
7 and < =
1⾯ ⼱1⽇
plexityissameastheworst-caseOM30neduplicatedkeylwh.ch
Asthishappened.the.com
eventuaytrmansubarraywithidenticaldementsintherecu.rs ion )
wouldresultinthiscaseonce-squadratic.com
plexiywithaconstantnumberofdist.netkeys
Question 2 .
3 -
way partition
5 inceweonlyhavetwodistincekeys.therecanonybe2.cases
Case
IǕ
Case
I.i-p-lapThistakesn-lcompa.is
ns.andthearrayissoreed-socnjnonly2possiblevalues
。
Question 3 ,
Ifwecando3-waypartitioninocnstimewe.ca
nthinkoftheduplicatedvaluesasonesinglevalue.SI
considerasThenwehavethe xactsamecaseastheor.si nd quicksort
samelowerboundocne.gr )