Linked List

A Linked List is a linear data structure where elements are stored in nodes, and each node points to the next node. It allows dynamic memory allocation and efficient insertion/deletion operations.

Linked List Visualization

Linked list is empty

Linked List: Empty

Complexity

Time Complexity: O(1) for insert/delete, O(n) for search
Space Complexity: O(n)

Pseudocode

class Node:
  data: value
  next: pointer to next node
  
class LinkedList:
  function insert(value, position):
    new_node = Node(value)
    new_node.next = current_node.next
    current_node.next = new_node
  
  function delete(value):
    find node with value
    previous.next = current.next