Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

ajprincess Group Title

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

  • one year ago
  • one year ago

  • This Question is Closed
  1. tyteen4a03 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • one year ago
  2. KonradZuse Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    ^That is wrong.

    • one year ago
  3. KonradZuse Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    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

    • one year ago
  4. ajprincess Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @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.

    • one year ago
  5. KonradZuse Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    I meant p = q * r, syntax fail on my part.

    • one year ago
  6. KonradZuse Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    p + r + d or (r*d) + d + r

    • one year ago
  7. ajprincess Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    u mean p+r+d=(q*r)+d+r?

    • one year ago
  8. ajprincess Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @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?

    • one year ago
  9. tyteen4a03 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @KonradZuse D'oh, messed up stacks with queues.

    • one year ago
  10. KonradZuse Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

    • one year ago
  11. KonradZuse Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    not too sure why r = r, but that's how it's supposed to be done.....

    • one year ago
  12. ajprincess Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    oh k. thank u soooo much @KonradZuse

    • one year ago
  13. KonradZuse Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    np, goodluck.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.