Professional Documents
Culture Documents
Sunbeam Infotech
ite) {
ian i
;
forcing
-
0 1 2 3 4 5
fooCj=o ; jam -
I;jtt) {
D) I 2 3 4 6 8
iffacj ) > a
D) I
4 9 swap ( ACD
a
innermost
,
)
j jtl i=o : 5 its
} Daca D
i=i : 5 its
i=Cn ④
-
-
§→
is : sites
T N2-2MT I
4 i =3 : 5 its
i=4 : sites
T4
'
n
-
@ -
1) camp
ite) {
ich i
;
foCi=o ;
-
0 1 2 3 4 5
ijjtt) {
fooCj=o;jcm -
I -
ifCacFFaCjtD ) 2 3 I 4 6 8
D) -
swapcacjs
f f
a
,
inner
3
loop
3 i-k-D-cm-DT.e.tl -
ix. : 5
'
Th m n
i. I• :
4
+150
-
i=2
.
:3
i=z : 2
-1=4 : I
is n i
;
it e) {
forcing
-
0 1 2 3 4 5
Flag false
Swap
=
;
{ 2 4 6 8
for a
;jcm -
I -
ijjtt) I 3
ifCaEjTFa D) E
( a CD a
D) -
f f
swap ,
swap tone :
flag -_
Best cage :
array already
g mmmm sorted .
i= n I
3
-
Th n - I
0④
Sunbeam Infotech www.sunbeaminfo.com
Insertion Sort 642831
68 2
I 3 4
0 1 2 3 4 5
~
I 2
a
3 46 8
④ 283 I
9 i=i
-1=2 246
- i=2
S
2468
-1¥ I 2 3 4 i=3
'
23 4 68 23468
^
i=4
8
9 I 234 6
I i=5
9
Sunbeam Infotech www.sunbeaminfo.com
Insertion Sort
is Itzt . .
-
+ G-D
is non D12 - 0 1 2 3 4 5
6 4 28 3 I
7LM 2- m
1 4 6
2
I
⑤ +3 276 ?⑤
4
2%6 ?①
F34 6EO
5 r -
0 1 2 3 4 5
I 23 4 68
/
Tan
BEI OCD
→
mmm
overheads
• Each node contains data and →
alloc
mmm
pointer/reference
F
to the-
next node. →
not contiguous
.
OCD
• addFirst() ✓
① random access →
• addLast() ✓
② fixed size
Ishoink of runtime .
• addAtPos() ✓
cannot grow
•
-
deleteFirst() ✓
③ contiguous allocation
• deleteLast() ,
overheads • deleteAsPos()
④ no
required
✓
extra space
no
• deleteAll()
-
✓
data elements
other than .
• traverse C) or display C)
20-0
d
223-00
n
d
33
n
q
• Singly circular linked list LEE IE9 3IM
• Doubly linear linked list
-
head
\
-
100
\
11 200 22 300 33 I
1002003007ft
y
Class My
list
{
static member
Hoda head ; class head
data { >
d n d n p d n
p
class Mode {
I ' '
20-0 E0223Y 33 I
,
display C)
{
data ,
ops{
type
ad ELI
date
mode next ;
nea '¥ ¥ son
100
{
=
0ps
¥rf
ioa✓
>
300 33
=
22300¥00
11 200 100 100
, ,
-
3; 3 z
display
④ 350 ⑤ %
q÷÷i
-
, →•
*
-
train =
trav.net ;
add Last C)
head not
100
L
11 200 22300 33 4×57
mum
441 @
4tour
-
& init it
sina.IE?jde./DFi?wnikfhI iI n'
nude list
empty ifinead - uD
.
① create new
② in
:[
node into next of last node
④
③ add new .
goo
next
-
train . = nm ;
③ head
Fido
44
If QQ 11 200 22 300 33 0
ahlocdinitnewnodemoden -neIII.
wtlodelraDi@nenwn .gh
①
¥0
emnnndeaad
node
③ head should be new .
400
head
9
head
100
2 3
5
I
11 200 22 300 33
④0 X 7 44 0
s£
¥aIH#④$
' oo z oo ggg 900
g
Stand:[I
↳ ¥
.
I 05¥
③ nn
Sunbeam Infotech www.sunbeaminfo.com
Linked List
HI;D
,
} 3
iqa
" " "°
¥°z ,
33 0
need
↳ 11 → 22 → 33
µT*a
→ 44 → ST
]
9 f
temp tour