Sunday, 15 July 2012

algorithm - How is these answers correct related to stacks -



algorithm - How is these answers correct related to stacks -

so next algorithm course of study princeton university done through coursera. doing question related stacks. reply baffles me. appreciate if can kindly show me going wrong in this;

question : suppose intermixed sequence of force , pop operations performed on lifo stack. pushes force letters through j in order; pops print out homecoming value. of next output sequence(s) occur?

correct reply 1 : b e d c g f j h

explanation : when g pushed, both , f still on stack. so, f popped before a.

my question : if f should appear before a, reply cannot true right?

correct reply 2 : b c e j h g f d

explanation : when e pushed, both , d still on stack. so, d popped before a.

my question : 1 time again d should come before right?

appreciate if can show me might doing wrong.

you right, both examples cannot happen, reasons explain. sure reading answers correctly? explanations reasons why output cannot happen, not why can.

algorithm stack

No comments:

Post a Comment