CSE 331: Introduction to Algorithm Analysis and Design
Fall 2011
Homework 9
Due Friday, November 18, 2011 by 1:15pm in class
Please submit each problem separately, i.e. each problem should begin on a new page and only the
pages for one problem should be stapled together. Failure to do so might result in some problem(s)
not being graded.
For general homework policies and our suggestions, please see the policy document.
Please make
sure you follow the collaboration policy.
Do not turn in Q 2(c).
1. (10 + 30 = 40
points
) We will consider the problem of exponentiating an integer to another.
In particular, for nonnegative integers
a
and
n
, deﬁne
Power
(
a,n
) be the number
a
n
. (For
this problem assume that you can multiply two integers in
O
(1) time.)
(a) (
NO collaboration allowed on this problem
) Present a naive algorithm that given
nonnegative integers
a
and
n
computes
Power
(
a,n
) in time
O
(
n
). (For this part, there
is no need to prove correctness of the naive algorithm.)
(b) Present a divide and conquer algorithm that given nonnegative integers
a
and
n
com
putes
Power
(
a,n
) in
O
(log
n
) time.
Note:
To get full credit you must present a recursive divide and conquer algorithm and
then analyze its running time by solving a recurrence relation. (Justify the correctness
of your algorithm– a formal correctness proof is not required.)
Hint:
The following mathematical identity could be useful– for any real numbers
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '11
 RUDRA
 Recursion, Big O notation, Divide and conquer algorithm, central node, Algorithm Analysis and Design

Click to edit the document details