Linked List Traversal Lesson xx

14
Linked List Traversal Lesson xx

description

Linked List Traversal Lesson xx. Objectives. Review building a complete linked list List traversal in main ( ) List traversal using a function. Complete List Traversal Program. struct entry { int value;   entry* next; }; - PowerPoint PPT Presentation

Transcript of Linked List Traversal Lesson xx

Slide 1

Linked List TraversalLesson xx

This module shows you how to walk through every node of a linked list. This procedure is called list traversal.

1ObjectivesReview building a complete linked listList traversal in main ( ) List traversal using a function

Our goal is to review building a linked list, do list traversal in main and then do list traversal using a function.2Complete List Traversal Programstruct entry { int value; entry* next; };

int main() { entry n1, n2, n3; entry* head = &n1; n1.next = &n2; n2.next = &n3; n3.next = 0; n1.value = 100; n2.value = 200; n3.value = 300; entry * temp; temp= head;

// traverse the list while (temp != NULL) { cout