Algorithm4_netalpha

Linked List

Node abstraction

private class Node
{
    Item item;
    Node next;
}

Building a linked list

To build a linked list that contains the items to, be, and or, we create a Node for each item, set the item field in each of the nodes to the desired value, and set the next fields to build the linked list.

Insert at the beginning

The easiest place to insert a new node in a linked list is at the beginning.

Remove from the beginning

Insert at the end

Traversal

for (Node x = first; x != null; x = x.next)
{
   // process x.item
}