Next: Q4: Divide and conquer
Up: CSL102: Special on-line examination
Previous: Q2: Divide and conquer
Consider the representation of an
-digit decimal number using an array of
elements, with one digit stored in each array element. For example,
512 is stored in an array
with:
.
(Note that the least significant digit is stored in
.)
Here is a divide and conquer strategy for multiplying two numbers stored in
and
.
- Input: Two arrays
and
of size
representing two
integers.
- If
multiply the digits and return the value.
= (leftmost
,rightmost
) digits
of
.
= (leftmost
,rightmost
) digits
of
.
-
-
-
- return
Show that the above strategy requires
steps. Write an imperative program based on the above idea.
You may write the program in any language of your choice. However it may
be simplest to complete
this Python program template.
Next: Q4: Divide and conquer
Up: CSL102: Special on-line examination
Previous: Q2: Divide and conquer
Subhashis Banerjee
2009-04-03