Computer Science: An Overview: Global Edition (12th Edition)

Published by Pearson Higher Education
ISBN 10: 1292061162
ISBN 13: 978-1-29206-116-0

Chapter 5 - Algorithms - Section 5.3 - Algorithm Discovery - Questions & Exercises - Page 233: 1

Answer

a)Code Algorithem in if-else condition b)667 c)experiment with small input values until you began to see a pattern.

Work Step by Step

a. if (n = 1 or n = 2) then (the answer is the list containing the single value n) else (Divide n by 3, obtaining a quotient q and a remainder r.) if (r = 0) then (the answer is the list containing q 3s) if (r = 1) then (the answer is the list containing (q 1) 3s and two 2s;) if (r = 2) then (the answer is the list containing q 3s and one 2) b. The result would be the list containing 667 threes. c. You probably experimented with small input values until you began to see a pattern.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.