2
Most read
3
Most read
5
Most read
Definition


Doubly is a type of linked list that
allows us to go in both directions

               and            in a linked list.




       Powerpoint Templates
                                       Page 3
A node in a doubly linked list
stores two references:
  - a next link, which points to the
    next node in the list,
  - a prev link, which points to the
     previous node in the list.




       Powerpoint Templates
                                   Page 4
Such lists allow for :
a great variety of quick update
operations, including insertion and
removal at both ends, and in the
middle.



          Powerpoint Templates
                                  Page 5
Header and Trailer Sentinels

      To simplify programming,
         it is convenient to add special nodes at
         both ends of a doubly linked list:
      • The header has a valid next
        reference but a null prev reference,
      • while the trailer has a valid prev
        reference but a null next reference.
       What is the Sentinels?
   A sentinel nodes do not store any elements.
and second name for sentinels node is “ Dummy ”

             Powerpoint Templates
                                                Page 6
Doubly Linked Lists
Figure 3.14:      A doubly linked list with sentinels, header and trailer,
   marking the ends of the list. An empty list would have these sentinels
   pointing to each other. We do not show the null prev pointer for the
   header nor do we show the null next pointer for the trailer.




                Powerpoint Templates
                                                               Page 7
Implementation
Deletion
Figure 3.15:      Removing the node at the end of a a doubly linked list with
header and trailer sentinels: (a) before deleting at the tail; (b) deleting at
the tail; (c) after the deletion.
Deletion
Code Fragment 3.18: Removing the last node of a doubly linked list. Variable
  size keeps track of the current number of elements in the list. Note that this
  method works also if the list has size one.
Insertion
Figure 3.16:       Adding an element at the front: (a)
during; (b) after.
Insertion
Code Fragment 3.19: Inserting a new node v at the beginning of a doubly
linked list. Variable size keeps track of the current number of elements in
the list. Note that this method works also on an empty list.
Powerpoint Templates
                       Page 13

Doubly linked list

  • 3.
    Definition Doubly is atype of linked list that allows us to go in both directions and in a linked list. Powerpoint Templates Page 3
  • 4.
    A node ina doubly linked list stores two references: - a next link, which points to the next node in the list, - a prev link, which points to the previous node in the list. Powerpoint Templates Page 4
  • 5.
    Such lists allowfor : a great variety of quick update operations, including insertion and removal at both ends, and in the middle. Powerpoint Templates Page 5
  • 6.
    Header and TrailerSentinels To simplify programming, it is convenient to add special nodes at both ends of a doubly linked list: • The header has a valid next reference but a null prev reference, • while the trailer has a valid prev reference but a null next reference. What is the Sentinels? A sentinel nodes do not store any elements. and second name for sentinels node is “ Dummy ” Powerpoint Templates Page 6
  • 7.
    Doubly Linked Lists Figure3.14: A doubly linked list with sentinels, header and trailer, marking the ends of the list. An empty list would have these sentinels pointing to each other. We do not show the null prev pointer for the header nor do we show the null next pointer for the trailer. Powerpoint Templates Page 7
  • 8.
  • 9.
    Deletion Figure 3.15: Removing the node at the end of a a doubly linked list with header and trailer sentinels: (a) before deleting at the tail; (b) deleting at the tail; (c) after the deletion.
  • 10.
    Deletion Code Fragment 3.18:Removing the last node of a doubly linked list. Variable size keeps track of the current number of elements in the list. Note that this method works also if the list has size one.
  • 11.
    Insertion Figure 3.16: Adding an element at the front: (a) during; (b) after.
  • 12.
    Insertion Code Fragment 3.19:Inserting a new node v at the beginning of a doubly linked list. Variable size keeps track of the current number of elements in the list. Note that this method works also on an empty list.
  • 13.