Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

state machine Problem 1. In the late 1960s, the military junta that ousted the government of the small republic of Nerdia completely outlawed built-in multiplication

state machineimage text in transcribed

Problem 1. In the late 1960s, the military junta that ousted the government of the small republic of Nerdia completely outlawed built-in multiplication operations, and also forbade division by any number other than 3. Fortunately, a young dissident found a way to help the population multiply any two nonnegative integers without risking persecution by the junta. The procedure he taught people is: procedure multiply(x; y: nonnegative integers) r:= x; S:= y; a:= 0; while (s = 0) do: if (313) then r=r+r+r; Si= /3; else if (3|(s 1)) then: a:= a +r; r=r+r+r; S := (s - 1)/3; else: a:= a +r+r; roor+r+r; S := (s-2)/3; return (a). (a) Model the algorithm as a state machine whose states are triples of nonnegative integers (r; s; a). (b) b List the sequence of steps that appears in the execution of the algorithm for inputs x = 5 and y = 10. (c) ) Use the Invariant Method to prove that the algorithm is partially correctthat is, if s = 0, then a = xy. (d) Prove that the algorithm terminates after at most 1 + logz y executions of the body of the do statement

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

Discuss the scope of financial management.

Answered: 1 week ago

Question

Discuss the goals of financial management.

Answered: 1 week ago

Question

=+Where do you want to live and work?

Answered: 1 week ago