L21lists - to traverse 1. allocate pointer variable for...

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

View Full Document Right Arrow Icon
Linked lists
Background image of page 1

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

View Full DocumentRight Arrow Icon
Definitions (linked) list is a data structure for efficient dynamic data storage node - element of a list data part - holds information contained in the list pointer (reference) part - a pointer to type(class) node nodes are allocated dynamically list is formed by having the reference part of one node point to the next node head (node) - first node in the list tail (node) - last node in the list the reference part of the tail points to NULL ‘a’ ‘b’ ‘c’ ‘d’ NULL ‘b’ (linked) list data part pointer part node head (node) tail (node)
Background image of page 2
List manipulation since head points to the next node and (transitively) to all the other nodes, all the information necessary to get the list data is a pointer to the head list traversal - going through list elements to collect information on the list’s structure or data stored
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: to traverse 1. allocate pointer variable for traversal ( ptr ) 2. assign address of head (from pointer to head) to ptr 3. look up the pointer part of node and assign it to ptr 4. Repeat step 3 until NULL is encountered since nodes are allocated dynamically, they can be removed and added to the list with only minimum modifications required a b c d NULL head (node) tail (node) pointer to head ptr ptr ptr ptr Review what is a list? what is a node? what does data part of node contain? what does the reference part of node contain? what is the head of a list? what is the tail of a list? what does the reference part of the tail of the list points to? what is list traversal? why would you want to traverse a list?...
View Full Document

This note was uploaded on 04/22/2010 for the course CS 23021 taught by Professor Staff during the Spring '08 term at Kent State.

Page1 / 4

L21lists - to traverse 1. allocate pointer variable for...

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

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