Uploaded by 邱嘎嘎吱

ALGO HW#1

advertisement
HW#2
E=
A EE
1.
The
proof
byinduction
is
Base Case
=
1
=
=
=
H(22+1)
Step
1
=
1 b
+
+
-..
+
H(2") 224,
+
=
21
1
-
By
n.
(n 0(
H12 H(1) 1
Inductive
on
M.I.,
we
2
+
2
+
in 2)+
+
+
zw4
-..
+
2271
+
proved
g+
+
...+
+
(2n+
+
-..
the
zn+1)
+
n +1
=
2
proposition.
I
+
2.
proof
This
byinduction
is
on n.
Base Case
For the smallest
binary
Thus, 17 2, my
=
Consider 7' derives
by replacing
with two
Using
By
=>
->
1y my 1
=
+
Step
Inductive
From 7
1
=
tree
to
one
new
7
leaf node
with
7'Om=My+
we
binary
an
tree I
internal mode
leaves.
/y m+1
M.I.,
from smallest
1
&
My 1
=>
proved
=
the
1 ly
=
1
+
1 my'
=>
proposition.
=
1
+
3.
proof
The
Base Case
We have
1
1.
selected
[1.2].
I divides 2.
and
numbers (called 3)
(n+1) 1
+
[1. 2n+2]. There would be
In+1, In+2 aren't
I
=>
contains
S1.2n]
the
2.
from
numbers
2
must be
select
we
from
select
to
Step
Inductive
If
m.
on
(U=1)
I
and
byinduction
is
By
Let
1
or
1.H.,
in
cases:
5
numbers
+2
one
of
from
which divides
other.
In+1, 2n+1
=>
at
both
I
S
are
in
S
S'r [In+1.
=
5 contains
a
numbers
2n
+23
from
(1. 2n)
a.
S' contains
n+
b.
1
is
n+
1
of
divider
a
3' doesn'tcontain
S'v (n+1)
2n+2
n+1
contain
=>
n+1
numbers
byI.H.
Thus,
there must be
Then,
n+1
isn't
a
one
divider
could divide another.
for any
i.S'contains two numbers
=>
divide another
ii.
S'
M.I.,
we
in
of
the
which
n+1.
know it's the divider
proved
in
[1, 2n)
one
could
one
contains the divider
could
By
[1. 2n]
in
proposition.
of
Then,
2n+2
we
4.
Base Case
(n=1)
G(1)
F(11 1
=
G(1)
=
=>
1 1 2
=
+
=
F(1)-1
Thus, induction
fails.
5.
(a)
MaxITI
I
0
max? I, Maxit.), MaxItrlS
(b)
Maxis
I
(max
-
11. Maxitis. Maxitus]
Maxis O
/max
11. Maxitis. Maxitus]
if
7
if
T node (k, t. tr)
if
7
if
7 node (k,t..tr)
if
7
if
7 node (k,t..tr)
1
=
=
1
=
=
1
=
=
Download