Write an algorithm for the implementation of a Doubly Linked List.

DOUBLY LINKED LIST -IMPLEMENTATION

In a singly linked list, each element contains a pointer to the next element. We have seen this before. In single linked list, traversing is possible only in one direction.

OTHER SOLVED ASSIGNMENT 2018-19

BCA 1

BCA 2

BCA 3

BCA 4

BCA 5

BCA 6

Sometimes, we have to traverse the list in both directions to improve performance of algorithms. To enable this, we require links in both the directions, that is, the element should have pointers to the right element as well as to its left element. This type of list is called doubly linked list.

NULL

DATA

RIGHT LINK

LEFT LINK

DATA

RIGHT LINK

 

LEFT LINK

DATA

NULL

Figure : A Doubly Linked List

Doubly linked list (Figure is defined as a collection of elements, each element consisting of three fields:

  • pointer to left element,
  • data field, and
  • pointer to right element.

Left link of the leftmost element is set to NULL which means that there is no left element to that. And, right link of the rightmost element is set to NULL which means that there is no right element to that.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!