H-SC COMS 262 - Lecture 19 - Circularly Linked Lists

Unformatted text preview:

Circularly Linked ListsExamplesBenefitsAssignmentCircularly Linked ListsLecture 19Section 11.2Robb T. KoetherHampden-Sydney CollegeMon, Mar 1, 2010Robb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 1 / 14Outline1Circularly Linked Lists2Examples3Benefits4AssignmentRobb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 2 / 14Outline1Circularly Linked Lists2Examples3Benefits4AssignmentRobb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 3 / 14Circularly Linked ListsDefinition (Circularly Linked List)A circularly linked list is a doubly linked list in which one additionalnode (the “dummy” node) is allocated, whose pointers serve as thehead and tail pointers. The dummy node’s data member is not used.Robb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 4 / 14Circularly Linked List Data MembersCircLinkedList Data Membersint mSize - The number of elements in the list.DoublyLinkedListNode*list - A pointer to the dummynode.Robb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 5 / 14Circularly Linked List NodesA CircularlyLinkedList uses DoublyLinkedListNodes.The dummy node is always allocated–even in an empty list.Robb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 6 / 14Circularly Linked List NodesmSizelista0an - 1Robb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 7 / 14Outline1Circularly Linked Lists2Examples3Benefits4AssignmentRobb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 8 / 14Implementing Member FunctionsWrite the insert() function.Robb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 9 / 14The CircLinkedList ClassThe header file doublylinkedlistnode.h.The header file circlinkedlist.h.The test program List Test.cpp.The executable.Robb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 10 / 14Outline1Circularly Linked Lists2Examples3Benefits4AssignmentRobb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 11 / 14Benefits of this ImplementationThe next pointer of the last node points to the dummy node, so itis not null.The prev pointer of the first node points to the dummy node, so itis not null.In fact, none of the pointers in the structure is null.Since there are no null pointers, the code in the member functionscontains no special cases!Robb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 12 / 14Outline1Circularly Linked Lists2Examples3Benefits4AssignmentRobb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 13 / 14AssignmentHomeworkRead Section 11.2, pages 589 - 591.Robb T. Koether (Hampden-Sydney College) Circularly Linked Lists Mon, Mar 1, 2010 14 /


View Full Document

H-SC COMS 262 - Lecture 19 - Circularly Linked Lists

Download Lecture 19 - Circularly Linked Lists
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 19 - Circularly Linked Lists and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 19 - Circularly Linked Lists 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?