Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Describe a recursive algorithm for multiplying two nonnegative integers x and y based on the fact that xy = 2 (x . (y / 2)) when y is even and xy = 2 (x . [y / 2]) + x when y is odd, together with the initial condition xy = 0 when y = 0 .

Short Answer

Expert verified

The recursive algorithm is,

procedure product (x,y : nonnegative integers)

if y = 0 then

return 0

else if

y is even then

return 2 . product (x, (y - 1) / 2) + x

else return 2. product (x, ()y - 1) / 2) + x

Step by step solution

Achieve better grades quicker with Premium

  • Unlimited AI interaction
  • Study offline
  • Say goodbye to ads
  • Export flashcards

Over 22 million students worldwide already upgrade their learning with Vaia!

01

Describe the given information

The objective is to write the recursive algorithm for the multiplying two nonnegative integers x and y based on the given fact.

The fact is,

When y is even,

xy = 2 (x.(y/2))

when y is odd,

xy = 2 (x . [y/2) + x

02

Write the recursive algorithm for multiplying two nonnegative integers x and y based on given fact

Call the algorithm "product" and the input are two nonnegative integers x and y.

procedure product (x,y : nonnegative integers)

When one of the integers is zero, then the product is zero.

if y = 0 then

return 0

Use xy = 2 (x. (y/2)) when y is even.

else if

y is even then

return 2. product (x,y / 2)

Use xy = 2 (x. [y/2]) when y is even.

else return 2. product (x,y / 2)

Use xy = 2 (x. [y/2]) when y is even.

else return 2. product (x,y : nonnegative integers)

if y = 0 then

return = 0

else if

y is even then

return 2. product (x,y / 2)

else return 2. product (x,y - 1) / 2 ) + x

Therefore, the recursive algorithm is shown above.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Which amounts of money can be formed using just two-dollar bills and five-dollar bills? Prove your answer using strong induction.

Let P(n)be the statement that 13+23+โ€ฆ+n3=(n(n+1)/2)2 for the positive integer .

a) What is the statement P(1)?

b) Show that P(1) is true, completing the basis step of

the proof.

c) What is the inductive hypothesis?

d) What do you need to prove in the inductive step?

e) Complete the inductive step, identifying where you

use the inductive hypothesis.

f) Explain why these steps show that this formula is true wheneveris a positive integer.

Prove that n2-1 divisible by 8 whenever n is an odd positive integer.

Let P (n) be the statement that a postage of n cents can be formed using just 3-cent stamps and 5-cent stamps. The parts of this exercise outline a strong induction proof that P (n) is true for n โ‰ฅ 8.

a) Show that the statements P (8), P (9), and P (10) are true, completing the basis step of the proof.

b) What is the inductive hypothesis of the proof?

c) What do you need to prove in the inductive step?

d) Complete the inductive step for k โ‰ฅ 10.

e) Explain why these steps show that this statement is true whenever n โ‰ฅ 8.

Assume that a chocolate bar consists of n squares arranged in a rectangular pattern. The entire bar, a smaller rectangular piece of the bar, can be broken along a vertical or a horizontal line separating the squares. Assuming that only one piece can be broken at a time, determine how many breaks you must successfully make to break the bar into n separate squares. Use strong induction to prove your answer

See all solutions

Recommended explanations on Math Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free