DoublyLinkedLists - Linked Lists For Linked Lists You...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Linked Lists For Linked Lists You Should Be Able To: • Append elements at either end. • Insert. • Delete at any position. • Perform traversals for various purposes. • Translate iterative algorithms to recursive ones and vice versa. • Things done in class not in textbook: Copy constructor. Reverse. Find. Counting. Among others... Template Linked List 1 template<c l a s s T> 2 c l a s s Node 3 { 4 public : 5 Node(T d) 6 { 7 data=d ; 8 next =0; 9 } 10 11 T data ; 12 Node<T> * next ; 13 } ; 14 15 template<c l a s s T> 16 c l a s s LinkedList 17 { 18 19 public : 20 LinkedList ( ) 21 { 22 head = 0 ; 23 t a i l = 0 ; 24 } 25 26 LinkedList 27 ( const LinkedList<T>& other ) ; 28 bool contains ( const T&); 29 void r e v e r s e ( ) ; 30 // Rest of public i n t e r f a c e . . . 31 32 pr i v a t e : 33 bool contains 34 (Node * n , const T&); 35 Node<T> * head ; 36 Node<T> * t a i l ; 37 } ; Doubly Linked Lists • LinkedList class de nition looks the same. • BUT Node class becomes: 1 template<c l a s s T> 2 c l a s s Node 3 { 4 public : 5 Node(T d) 6 { 7 data=d ; 8 prev=next =0;...
View Full Document

This note was uploaded on 02/27/2012 for the course IT 101 taught by Professor Unsure during the Spring '11 term at University of South Africa.

Page1 / 11

DoublyLinkedLists - Linked Lists For Linked Lists You...

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

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