Consider the following piece of pseudocode: function Thing(n) if n <3 then return 1 end if new Stack s PUSH[1, s] PUSH[1, s] for 3

Algebra & Trigonometry with Analytic Geometry
13th Edition
ISBN:9781133382119
Author:Swokowski
Publisher:Swokowski
Chapter9: Systems Of Equations And Inequalities
Section9.6: The Algebra Of Matrices
Problem 36E
icon
Related questions
Question
. Consider the following piece of pseudocode:
function Thing(n)
if n < 3 then
return 1
end if
new Stack s
PUSH[1, s]
PUSH[1, s]
for 3 ≤ i ≤n do
x ← TOP [s]
POP[s]
y ← TOP[s]
PUSH[x, s]
PUSH(x + y, s]
end for
return TOP[s]
end function
What is returned by the function call Thing(7)?
Transcribed Image Text:. Consider the following piece of pseudocode: function Thing(n) if n < 3 then return 1 end if new Stack s PUSH[1, s] PUSH[1, s] for 3 ≤ i ≤n do x ← TOP [s] POP[s] y ← TOP[s] PUSH[x, s] PUSH(x + y, s] end for return TOP[s] end function What is returned by the function call Thing(7)?
Expert Solution
steps

Step by step

Solved in 7 steps with 44 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Algebra & Trigonometry with Analytic Geometry
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:
9781133382119
Author:
Swokowski
Publisher:
Cengage
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
Algebra: Structure And Method, Book 1
Algebra: Structure And Method, Book 1
Algebra
ISBN:
9780395977224
Author:
Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. Cole
Publisher:
McDougal Littell