Question: Alg mystery(n) input: positive integer n While n > 0 do r = n % 2 tmpstack.push(r) n = n/2 while tmpstack.size() > 0 do
Alg mystery(n)
input: positive integer n
While n > 0 do
r = n % 2
tmpstack.push(r)
n = n/2
while tmpstack.size() > 0 do
r = tmpstack.pop()
print(r)
1. What is the output from the print statement when n = 5
2. What is the output from the print statement when n = 10
3. Explain what is the use of tmpstack in this algorithm
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
