) i indicakes the soi ted and
boundanyal
Gttven avay aftea tuwÙ pases is
98
that m eau 3 13 conted part
G» i- 3
Cwvent (3] 26
j- 3- e
23 98
Compare aG with 3, 13, 3 skes no shift needed
)
343 3 26 23 48 S
j= 3
no shift needed.
Compane
(5) 3 78 3 6
ie 5 Curent ) a3
98, S
j: a’ no shit then
3||13 23 26
wnent = 98 js5
Compare
no shifts nee oled
23 24
3 4 13
tóppCY i=, Cwvent= j= 6
13: 23 26 (n448)
de no mee shlts. (57 >u),
|3| 13 23 26| sa98
final Sorted Aay
we
1P
we Smallest [|8113 Smallest 35
4
Smallest 4 Smallest 5continwe | c13 Swopping smallest
Swarping 8 04be *\813|Swappinq Swappina(3],
13 got
l2t3]l48 3 23 |23
teso
dy 26]b 23 23usolteday 23 4
au6), amone 26 |26 Uni]
26 |26| 26 4
26
pase
|98| 13
aa e 23 ,
/9s) uts] auty
28 8 98
(1) 98
s S s|
SA s $
(a
ftmallest
1)
’ MAY HEAP
(0 swop
() Suwop6 ond 3s
36
Suap 6 and
sludl336sal2\ 34 sta3
) Ustng the bubble Sht that stans ro
and
bubbles up the smatlest elemeot:
Mears, Rhst Aoop 0ould uun yom
to Site -g
and and Aoop
7om sze-1 to t.
Gtven away ofte a paes
7 and 8 e
bubbled up.
th pas i 4 8 13\26 uy 23 S+
4 8 13 26
|a |s|3 23 | 26|u|sl981
Sth pas: %I3 23 26 st Q%
+8 13 23 26
|a)sl13|3l24lul sl ss
Gh pas: 8 3 23
|33 (2326l ulsals8 tnal Soted ay
4 8 13 23 26 u4s s
Ffnal Stnted Aray
Giyen ovay 22,4 ,34, ,38,3,s
Ipt
Let last element ie s to be the
pivot.
NOw, we place al the elements tha ae les than
ptvot to the Set and elemens hat e
reate than pivot to atht od pivot.
To do 4his Use tw0 polnteu te rom i=
and j from O.
Cont pouLe with pivot, if it is Aen hat pivot
ond Suap ai3 and au ]
we wtl ncement (
This wU conttnue untl Aea ches high -. pivot
eivot =5
34
44 22 B8 2 38 & & 98 SG 1%
34 36 3s
i will beome
Now, become Gtig
AFter oop, we wil swap ahiqh] ond aun
we wiU
That meany, pivot tndex is 1.
After Suwapping
56
22 34 2
piVot =S
Le ft Sublist: 22 # 34 2 38
3y D5
Pivot = s
Riqht Su bist: 8 98 56
3 2| 32 S6 92
)Reanangment atea peses
92
3 t 32 s A, 32 J6 )
manway we qet, 3
ae sot this
tuO elemens
two
Smallest and
and turo logut
Here, ight respettve posiion.
soted at thei
sot.
could be bubble a sele otion
So it
Bubbk sot:
2 32 S 92
3
lst Ps:
92 fuitheres
49 5 Swaps
3 sl 32
no
and pasi 3 21 32 uT St 92 needed.
fwth
No swaps
wi~h gives Neawangement.
does not mateh
Sele tton Sont: t 3 2l 32 S6 42
tst pas: smallest s 92
3 t 2t 32
2
and pax : Smaest z
given
gven
tavangmen
TE ma tehes
i t s Selecfion Sot.
So
Orginal 8O 12 66 21
2l 33h
33
Ater a paue: 4 33 So 72 66 4y
42 $0
Sont. as argest lement
a
I4 is not Gubble
bubbled at end.
not
seleetion o tnietion
It coutd be ether
Selection Sott:
Ist pas
Swop aulo) and atu 2t 12 GG
Jnd pass smalest :* x 35
4 do not math given 2eauangment.
Tnsertion Sert: 80 32 G6 2 33
2 60| 66 4 2 33
tst pass:
and 21 33
at also do not math thiven neaMargmert d
J do rat mateh any ot 3
behavto Suggest tt may be seleetionsot as
Least elements have been placed af tirst platu
used. being tsSetinsentton
Nangement. qiven thematches T4
92
6G
4?| 3
92 32
S 32 66
92 S32 66
Sot: Trserton
[Link] be may
posittong. 9 tst fn
ced amog smallest two cause be(olt
n Conrot
be also tt bbled bu ane
en Jargest
telerr Sasgeit tuo sot bubble cannot
be 1t
92 66 56 47 3) 3sot:manually we 7f
psges: Aster
o MerqeSont: mid &
9,23,56, 4,2,58, 22,33, Gu, lu, 11, 54, I!, 35,46, 09
mid =y
23 56 G 5 12 GS 18
34 9
m2 22
4
37 9 23 S
4l a $+
5 2 22 33
34 9 23 $? V
12
22 33
3 9 S 2
22 33
23 SG 11,3S9
S,2, 45,t8
4,23,S6
9,34 22,33,44
4,,23,34, 14,22,33, u44S
I4,
33,35,i9,S9,6
I,4,13,22,
9,2 ,23, 34,46, $6,18
4,5,
44G, 8,49,56,,t8
3,35,37,
! ,22, 23,3
4,5,9,, 12, I4,
shel sot obh
(ompaning & sot'ng9 the' elemen ts at posibm
O, 3,6,$ 12'
Element: 23 3 66
After sovtng by inaertion sot
I3,23,44, s6, 98
ot positrory I, 42,10, 3
Elemerk: 3,69, 2,1,18, 54
ePter Sotng, 2, 3, 8, s2, 89
2, S, &,
Elermen t: a,, 6,90
Ateu soing G,3,,90
when place 4hem in -theit ginal positHony
get
13, 2, 6, 23, 3,4, 4, 8, 66, S,9O, 98,89