lc3 - Are these output streams possible? -


i working on practice exam question

a the problem stack machine has input stream of abcd. possible output stream of cdba? cdab? show sequence of operations create these streams or if not possible explain why not possible.

i said both output streams possible.

for cdba, here sequence of operations create such stream

  1. push a
  2. push b
  3. push c
  4. pop c/store
  5. push d

for cdab

  1. push
  2. pop a/store
  3. push b
  4. push
  5. push c
  6. pop c / store
  7. push d
  8. push c

i assumed stack machine works stack -push pop. agree 2 sequences of operations? there property of "stack machine" makes these streams impossible create/produce?

yup, looks except need push c again @ end of cdba.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -