Handouts LectureSlides Lecture5 2
Handouts LectureSlides Lecture5 2
version
An
alterna0ve
is
to
think
of
this
computa0on
as:
a
*
b
=
a
+
a
+
+
a
b
copies
=
a
+
a
+
+
a
b-1
copies
=
a
+
a
*
(b
1)
Recursion
This
is
an
instance
of
a
recursive
algorithm
Reduce
a
problem
to
a
simpler
(or
smaller)
version
of
the
same
problem,
plus
some
simple
computa0ons
Recursive
step
a
*
b
=
a;
if
b
=
1
(Base
case)
a
*
b
=
a
+
a
*
(b-1);
otherwise
(Recursive
case)