Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Algorithm for adding two m-digit numbers: Assume the algorithm is called with the following inputs: a = 73, b = 42. (i) Determine the value

Algorithm for adding two m-digit numbers:

image text in transcribed

Assume the algorithm is called with the following inputs: a = 73, b = 42.

(i) Determine the value of m. Show all work.

(ii) What is the largest number that can be represented with this value of m? Show all work.

(iii) What are the values of ai and bi that will be used in the algorithm?

(iv) What is the continuation condition of the loop in the above algorithm? Write the pseudocode as it appears above.

(v) Trace through the m-digit addition algorithm, step-by-step.

FIGURE 1.2 Given: m1 and two positive numbers each containina m digits, a a and bm2.bo Wanted: cm Cm1 Cm 2... Co, where Cm C-1 Cm2. . Co a, m- m-2 Algorithm: Step 1 Set the value of carry to 0 Step 2 Set the value of i to O Step 3 While the value of i is less than or equal to m - 1, repeat the instruc- tions in Steps 4 through 6 Step 4 Step 5 Add the two digits a, and b, to the current value of carry to get c If c z 10, then reset c to (c 10) and reset the value of carry to 1; otherwise, set the new value of carry to 0 Add 1 to i, effectively moving one column to the left Step 6 Step 7 Step 8 Step 9 Set cm to the value of carry Print out the final answer, Cm Cm-1 Cm-2 Stop Co FIGURE 1.2 Given: m1 and two positive numbers each containina m digits, a a and bm2.bo Wanted: cm Cm1 Cm 2... Co, where Cm C-1 Cm2. . Co a, m- m-2 Algorithm: Step 1 Set the value of carry to 0 Step 2 Set the value of i to O Step 3 While the value of i is less than or equal to m - 1, repeat the instruc- tions in Steps 4 through 6 Step 4 Step 5 Add the two digits a, and b, to the current value of carry to get c If c z 10, then reset c to (c 10) and reset the value of carry to 1; otherwise, set the new value of carry to 0 Add 1 to i, effectively moving one column to the left Step 6 Step 7 Step 8 Step 9 Set cm to the value of carry Print out the final answer, Cm Cm-1 Cm-2 Stop Co

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago

Question

Influences on Nonverbal Communication?

Answered: 1 week ago