Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 847 Bytes

doublyLinkedList.md

File metadata and controls

23 lines (16 loc) · 847 Bytes

Doubly linked list

A bit similar to a singly-linked list, a doubly-linked list is a linked list made of nodes, except that the nodes contain a third field with a link to the previous node as well as the next node.

The advantage of a doubly linked list is that we can traverse back to the previous node for deletion for example. The operations are bi-directional.

Node:

  • data stores the value
  • previous points to the previous node in the list
  • next points to the next node in the list

Operations:

  • _length
  • head
  • tail
  • add(value)
  • searchNodeAt(position)
  • remove(position)

For details on how to implement doubly-linked lists in JavaScript, check out this article