View on GitHub

reads

https://yazansneneh.github.io/reads/

Linked Lists

Linked list types:

  1. singular list: is a list where each node contain only 1 reference that refer to the next node.
  2. doubly list: is a list where each node contian 2 refrences, one refer to next node and other refer to prevous node.
  3. circular: is a linked list where each node contain 2 references, exactly like the doubly, the only difference is that the last node in the list refer to the first node in the list.

**Example : ** View double and single lists

Traversal

Big O

Add a Node

example of adding a node : Order here is intended to add new node without losing reference.

ALGORITHM Add(newValue)
// INPUT <-- Value to add
// OUTPUT <-- No output

  newNode <-- NEW Node
  newNode.Value <-- newValue
  newNode.Next <-- Head
  Head <-- newNode

reference Code fellows

find and print a node

Example:

ALGORITHM Print()
// INPUT <-- None
// OUTPUT <-- string to console

  Current <-- Head

  WHILE Current is not equal to NULL
    OUTPUT <-- "{Current.Value} --> "
    Current <-- Current.Next

  OUTPUT <-- "NULL"

reference Code fellows