Consider the following algorithmic procedure: Input :Non-negative integers x, y Output :Non-negative integer a r:= x; s:= y; a := 0; while s + 0 do if 3 | s then r:=r+r+r; s:= s/3; end else if 3| (s - 1) then a := a+r; r:=r+r+r; s:= (s – 1)/3; end else a:= a+r+r; r:=r+r+r; s:= (s – 2)/3; end end return a Algorithm 1: Multiply We can model Algorithm 1 as a state machine whose states are triples of non-negative intege (r, s, a). The initial state is (x, y, 0). The transitions are given by the rule & that for s > 0: if 3 | s 8(r, s, a) = {(3r, (s –1)/3,a+r) if 3| (s – 1) |(3r, (s – 2)/3,a+2r) otherwise. ((3r, s/3,a) 1. List the sequence of steps that appears in the execution of the algorithm for inputs x = and y = 10. In other words, walk us through the algorithm starting from the initial state ar ending with the final state.

Linear Algebra: A Modern Introduction
4th Edition
ISBN:9781285463247
Author:David Poole
Publisher:David Poole
Chapter2: Systems Of Linear Equations
Section2.4: Applications
Problem 33EQ
icon
Related questions
icon
Concept explainers
Topic Video
Question
100%

It is a discrete math problem. I need your help with the question attached.thanks. 

Consider the following algorithmic procedure:
Input :Non-negative integers x, y
Output :Non-negative integer a
r:= x;
s:= y;
a := 0;
while s + 0 do
if 3 | s then
r:=r+r+r;
s:= s/3;
end
else if 3| (s – 1) then
a := a+r;
r:=r+r+r;
s:= (s – 1)/3;
end
else
a:= a+r+r;
r:=r+r+r;,
s:= (s - 2)/3;
end
end
return a
Algorithm 1: Multiply
We can model Algorithm 1 as a state machine whose states are triples of non-negative integers
(r, s,a). The initial state is (x, y, 0). The transitions are given by the rule & that for s > 0:
[(3r,s/3,a)
if 3 | s
8(r, s, a) = {(3r, (s– 1)/3,a+r) if 3 |(s – 1)
|(3r, (s – 2)/3,a+ 2r) otherwise.
1. List the sequence of steps that appears in the execution of the algorithm for inputs x = 5
and y = 10. In other words, walk us through the algorithm starting from the initial state and
ending with the final state.
Transcribed Image Text:Consider the following algorithmic procedure: Input :Non-negative integers x, y Output :Non-negative integer a r:= x; s:= y; a := 0; while s + 0 do if 3 | s then r:=r+r+r; s:= s/3; end else if 3| (s – 1) then a := a+r; r:=r+r+r; s:= (s – 1)/3; end else a:= a+r+r; r:=r+r+r;, s:= (s - 2)/3; end end return a Algorithm 1: Multiply We can model Algorithm 1 as a state machine whose states are triples of non-negative integers (r, s,a). The initial state is (x, y, 0). The transitions are given by the rule & that for s > 0: [(3r,s/3,a) if 3 | s 8(r, s, a) = {(3r, (s– 1)/3,a+r) if 3 |(s – 1) |(3r, (s – 2)/3,a+ 2r) otherwise. 1. List the sequence of steps that appears in the execution of the algorithm for inputs x = 5 and y = 10. In other words, walk us through the algorithm starting from the initial state and ending with the final state.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Application of Algebra
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, advanced-math and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Linear Algebra: A Modern Introduction
Linear Algebra: A Modern Introduction
Algebra
ISBN:
9781285463247
Author:
David Poole
Publisher:
Cengage Learning
Elements Of Modern Algebra
Elements Of Modern Algebra
Algebra
ISBN:
9781285463230
Author:
Gilbert, Linda, Jimmie
Publisher:
Cengage Learning,
Algebra & Trigonometry with Analytic Geometry
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:
9781133382119
Author:
Swokowski
Publisher:
Cengage