CHAP16 - Chapter 16 Linked Structures Chapter 16 LINKED...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 16 Linked Structures Chapter 16 LINKED STRUCTURES CHAPTER GOALS To understand the concept of a linked data structure. To be able to declare the data types and variables needed for a dynamic linked list. To be able to print the contents of a linked list. To be able to insert new items into a linked list. To be able to delete items from a linked list. CHAPTER OUTLINE I. Sequential Versus Linked Structures II. Array Representation of a Linked List III. Dynamic Data Representation of a Linked List A. Algorithms on Dynamic Linked Lists 1. Creating an Empty Linked List 2. Testing for an Empty Linked List 3. Printing a Linked List 4. Inserting into a Linked List 5. Deleting from a Linked List B. Pointer Expressions C. Classes and Dynamic Linked Lists IV. Choice of Data Representation V. Problem-Solving Case Study : Simulated Playing Cards VI. Problem-Solving Case Study : Solitaire Simulation VII. Testing and Debugging A. Testing and Debugging Hints VIII. Summary GENERAL DISCUSSION Chapter 16, building on the groundwork laid in Chapter 15, uses dynamic data and pointers as the building blocks for most of the linked list algorithms. Other than forward (incomplete) declarations of struct s, this chapter does not introduce any new C++ language features, so instructors and students can focus primarily on the general concepts. The first section of the chapter sets the stage for the study of linked lists. The linked list introduces the idea that a data structure can be built from nodes, each of which contains not only data but also an indication of where to find the next node in memory. In some ways, the linked list is to data structures what a control structure is to program execution—a means of establishing a logical order that is different from the physical ordering of data. Thus, a data structure may contain information that affects its organization. Linked lists change the programmer's notion of which operations are costly. For example, insertion into a list is very time consuming with a direct array representation but can be done quickly in a linked list. 70
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Chapter 16 Linked Structures The second section of the chapter shows how to implement a linked list by using an array of struct s. This section is important because it emphasizes the fact that a linked list is an abstraction and, as such, can have alternative implementations. Instructors of upper-division courses will relate immediately to our observation that students almost invariably equate linked lists with dynamic data and pointers, whereas system-level software generally uses the array-of- struct s implementation for speed. It's important for students to be exposed to both implementations and to know that both are widely used. Figure 16-5 summarizes the levels of abstraction by displaying an implementation hierarchy for the list ADT. This figure shows that a list can be implemented either with an array of the component type (which is inefficient if insertions and deletions are frequent) or with a linked list. Furthermore, a linked list can be implemented with
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/13/2011 for the course CSC 240 taught by Professor Lebre during the Spring '04 term at Moraine Valley Community College.

Page1 / 22

CHAP16 - Chapter 16 Linked Structures Chapter 16 LINKED...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online