Chapter 4

Stacks and Queues


We are familiar with arrays and the operations performed on them. The various elements can be accessed from any position in a list, stored in an array. Some practical applications require that the additions or deletions be done only at one end. For example, the packets of wheat floor received in a super bazaar are put on top of another in the order of their arrival. Now, a customer can remove only the packet currently lying on the top, i.e., the last packet arrived in the bazaar is the first one to leave. The second customer would get the second last packet and so on. In the mean time, if more packets arrive then they will be added on the ...

Get Data Structure Using C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.