Lecture 12

1 2 add the remaining integers head new node head data

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: he “tail” pointers must be initialized. 1 2 Add the Remaining Integers head = new node; head data = NextValue; head next = NULL; node *tail = head; In the while loop, new elements are added to the end of the existing list. tail next = new node; tail = tail next; tail data = NextValue; tail next = NULL; 3 4 CIRCULAR LINKED LISTS Safe programming requires that all programs work for an empty input list without crashing. Basic Idea: Let the last struct pointback to the first struct. if (F >> NextValue) { // add first element // add rest of elements } else head = NULL; // emp...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online