Previous Section
 < Free Open Study > 
Next Section


Chapter 5: Linked Structures

Goals

After studying this chapter, you should be able to

In the last two chapters, we examined array-based implementations of four very useful ADTs: the Unsorted List, the Sorted List, the Stack, and the Queue. Unfortunately, the array-based implementation has a serious drawback: The size of a structure must be determined when an object is declared. When we declare a variable of the class UnsortedType, SortedType, StackType, or QueType, the maximum number of items is passed as a parameter to the constructor, and an array of that size is allocated. Most of these classes in the last 2 chapters used static, not dynamic, allocation of the array. If we use fewer elements, space is wasted; if we need to store more elements than the array can hold, we cannot do so. Ideally, we could just get space for elements on these structures as needed.

Dynamic allocation of each element-one at a time-allows us to do just that.



Previous Section
 < Free Open Study > 
Next Section
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)