Dale - Computer Science Illuminated 307

Dale - Computer Science Illuminated 307 - – 1 In a linked...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
280 Chapter 9 Abstract Data Types and Algorithms Figure 9.4 Anatomy of a linked list list User's data Pointer to next item in the list End of list Figure 9.5 An unsorted linked list list 60 75 95 80 65 90 Figures 9.5 and 9.6 display the lists in Figures 9.2 and 9.3, respectively. We call the user’s information the info part of the node and the pointer the next part of the node. In an array-based list, we access each item by using a variable that ranges from 0 through length
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: – 1 . In a linked list we use a variable of the same type as the next part of the node; let’s call it current . current is initialized to list , the first node in the list. info(current) accesses the user’s data in the node and next(current) accesses the pointer part of the node. To move to the next node in the list, we set current to next(current) . The last item has been accessed when current is equal to null ....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online