Section 8.3
233
Step 1: Set
F
=
O.
Step 2:
If
£"1 is empty, set £"3
=
£"2 and
F
=
1.
£"2 is empty, set £"3
=
£"1 and
F
=
1; otherwise
let £"3 be the empty list and proceed to Step 2.
Step 3:
F
=
0, do the following:
Suppose
a1
~
b1.
Then append
to £"3 and, if this empties £.,}, append the elements of £"2 to £"3
and stop.
r
elements remain in £"1 and
r
#
0, then label them
a1, a2,
... ,
a
r
in increasing order
and repeat Step 2.
Suppose
>
b
1.
Then append
b
1
to £"3 and, if this empties £"2, append the elements of £"1 to £"3
and stop.
r
elements remain in £"2 and
r
#
0, then label them
b
1 ,
b
2 ,
••• ,
b
r
in increasing order
and repeat Step 2.
Eventually, one of the lists is empty, so
F
is set to 1 at Step 2 and the lines following the "If' statement
in Step 3 are ignored.
13. (a) [BB] Here's the bubble sort:
14.
k
=
5: 3,1,7,2,5,4
+
1,3,7,2,5,4
1,3,2,7,5,4
f,3,2,5, 7,4



k
=
4:
~,2,
5,4, 7
1,~,5,4,
7
1,2, 3, 5,4, 7
1,2,3, 5,4, 7
k
=
3:
~,3,4,5,
7
1,~,4,5,
7
1,2,3,4,5,7
k
=
2:
~,3,4,5,
7
1,~,4,5,
7
k
=
1:
~,3,4,5,
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 11/08/2010 for the course MATH discrete m taught by Professor Any during the Summer '10 term at FSU.
 Summer '10
 any
 Graph Theory

Click to edit the document details