Search code examples
phpstackqueue

stack vs queuing?


hello im still a student and im a bit confused about stacking and queuing ? first question is,

  1. what is the main diffrence between them two ?

  2. btw there is circular queuing beside normal queuing how about that ? how do they work ? is there any different ways to queuing?

  3. im useing php, is there a simple ( very simple or easy to read ) sample code that i can learn on ( links are okay too. )?

  4. there is pop, push and etc ( stacking and queuing ), is there anything like that in php ?

Thank you very much for looking in.


Solution

  • 1: While with stacks the insert/removal operations both work on the same end of the data structure (top)

    with queues the insertion takes place at one end (rear) and the removal at the other end (front).

    (Both images are from the respective wikipedia entries)

    2: see http://en.wikipedia.org/wiki/Circular_buffer

    3: and 4: see SplStack and SplQueue