1 / 7

Data Structures CSCI 132, Spring 2019 Lecture 21 Doubly Linked Lists

Data Structures CSCI 132, Spring 2019 Lecture 21 Doubly Linked Lists. Doubly Linked Lists. Doubly linked lists have pointers to both the next node and the previous node in the list. The data members for this class would be: int count; mutable int current_position;

stella
Download Presentation

Data Structures CSCI 132, Spring 2019 Lecture 21 Doubly Linked Lists

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data StructuresCSCI 132, Spring 2019Lecture 21Doubly Linked Lists

  2. Doubly Linked Lists Doubly linked lists have pointers to both the next node and the previous node in the list. The data members for this class would be: int count; mutable int current_position; mutable Node<List_entry> *current; entry 0 entry 1 entry 2 current

  3. Nodes for doubly linked lists template <class Node_entry> struct Node { //Data members Node_entry entry; Node<Node_entry> *next; Node<Node_entry> *back; //Constructors Node(); Node(Node_entry, Node<Node_entry> *link_back = NULL Node<Node_entry> *link_next = NULL); };

  4. set_position( ) for doubly linked lists template <class List_entry> void List<List_entry> :: set_position(int position) const // Set current to point to node at position specified in parameter { //we will fill this out in class. }

  5. Advantages of linked lists Advantages: Disadvantages:

  6. Linked vs. Contiguous lists Use contiguous lists when: Use linked lists when:

  7. Linked Lists in Arrays Store items in one array. Store "pointers" in a second, parallel array. Each "pointer" is the index of the next item in the list.

More Related