ajprincess
  • ajprincess
Please help:) Show the state of the stack and the value of each variable after execution of each of the following statements: p=2.5 q=3.30 r=7.003 d=0.00026 create stack push q onto stack push d onto stack pop item from stack push r onto stack push p onto stack p=q*r push p+r+d onto stack pop item from stack and store in p pop item from stack and store in q pop item from stack and store in r
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
tyteen4a03
  • tyteen4a03
Create Stack: *bzzt* Push q onto stack, stack becomes [q] Push d onto stack, stack becomes [q, d] pop item from stack, stack becomes [d] push r onto stack, stack becomes [d, r] push p onto stack, stack becomes [d. r. p] p=q*r, stack becomes [d, r, q*r] push p+r+d onto stack, stack becomes [d, r, q*r, p+r+d] pop item from stack and store in p, p becomes d pop item from stack and store in q. q becomes r pop item from stack and store in r, r becomes q*r.
KonradZuse
  • KonradZuse
^That is wrong.
KonradZuse
  • KonradZuse
create stack push q onto stack[q] push d onto stack[q,d] pop item from stack[q] push r onto stack[q,r] push p onto stack[q,r,p] p=q*r // do nothing push p+r+d onto stack[q, r, p, (p[q * r]+r+d)] pop item from stack and store in p [q,r,p] // (p[q * r]+r+d)] = p pop item from stack and store in q [q,r] // p = q pop item from stack and store in r [q] // r = r

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

ajprincess
  • ajprincess
@KonradZuse Can u please explain me the line push p+r+d onto stack[q, r, p, (p[q * r]+r+d)] Why it is p[q*r]? I dnt get that part.
KonradZuse
  • KonradZuse
I meant p = q * r, syntax fail on my part.
KonradZuse
  • KonradZuse
p + r + d or (r*d) + d + r
ajprincess
  • ajprincess
u mean p+r+d=(q*r)+d+r?
ajprincess
  • ajprincess
@KonradZuse so it will be create stack push q onto stack[q] push d onto stack[q,d] pop item from stack[q] push r onto stack[q,r] push p onto stack[q,r,p] p=q*r // do nothing push p+r+d onto stack[q, r, p, ([q * r]+r+d)] pop item from stack and store in p [q,r,p] // ([q * r]+r+d)] = p pop item from stack and store in q [q,r] // p = q pop item from stack and store in r [q] // r = r. Isn't t?
tyteen4a03
  • tyteen4a03
@KonradZuse D'oh, messed up stacks with queues.
KonradZuse
  • KonradZuse
yes remember queues are first in first out(think of a line of school children, or lunch line) then stacks are first in last out, so think of a stack of papers. If you put a papper at the bottom, you need to do all the papers on top of it first to get to that one paper.
KonradZuse
  • KonradZuse
not too sure why r = r, but that's how it's supposed to be done.....
ajprincess
  • ajprincess
oh k. thank u soooo much @KonradZuse
KonradZuse
  • KonradZuse
np, goodluck.

Looking for something else?

Not the answer you are looking for? Search for more explanations.