Abstract
In Section 16.4, we presented a module for handling several stacks. Although the definition module was well designed, it did have one important drawback: the maximum number of elements in a stack had to be defined. The reason for this was that the stacks were implemented using arrays. Typically, a stack differs from an array, because the number of elements in a stack is always varying. We say that an array is a static data structure, whereas a stack is a dynamic data structure. To simulate this dynamic structure using an array, we introduced an index (called Top) which indicated the element which was last entered on the stack. As illustrated in Fig. 19.1, if the maximum size of the array is 50, the only difference between a stack of 5 elements and a stack of 49 elements is the value of Top. The space required for 50 elements is reserved, even if it is not necessary.
Keywords
Binary Tree Dynamic Variable Pointer Type Dynamic Allocation Fifo QueuePreview
Unable to display preview. Download preview PDF.