QA
Dashboard

Linked Lists in dsa

Linked lists consist of nodes containing data and a pointer to the next node. Unlike arrays, elements are not stored contiguously. Insertion/deletion at a known node is O(1), but accessing an element by index is O(N).

Example

class Node {
  constructor(data) {
    this.data = data;
    this.next = null;
  }
}

Singly linked lists have unidirectional pointers, while doubly linked lists have pointers to both next and previous nodes.