Question

Consider the following algorithm: ocedure Algorithm (b: integer, n: positive integer,i datinct integem) proc answer :, 0 nan
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) the below output is as per print statement in the algorithm

j z b answer
2 28 17 0
3 35 17 0
4 23 17 0
5 41 17 0

b) answer = 17

Reason: when j=5, then while condition becomes false as b is equals to z that is 17.
   then it exits the while loop and jumps to if condition.
   then if condition becomes true that is 5 is less than 9. So answer = 5

c) total number of comparisons = 4+1 = 5 as 4 comparisons in while loop and one final comparison in if condition.

Add a comment
Know the answer?
Add Answer to:
Consider the following algorithm: ocedure Algorithm (b: integer, n: positive integer,i datinct integem) proc answer :", 0 nand 6 while (j print(j, z, b, answer) if jSn then answer:-j return a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT