Wednesday, April 23, 2014

Inserting into a Single Linked List

Note - The code examples used in this post are located at my GitHub account - Single Linked Lists

We have previously covered the process of performing a search on a single linked list. In that post, we used a pre-constructed list to provide the basis of our search operation.  Whilst that demonstrated how to go about searching through a single linked list, it didn't shed much light on how we could build our own lists from scratch. In this post, we'll cover the second of the three basic operations of a single linked list, insertion

Wednesday, April 16, 2014

Single Linked Lists (Searching)

Note - The code examples used in this post are located at my GitHub account - Single Linked Lists

A single linked list is the simplest of the linked structures. It comprises of a group of nodes that are connected together in a directional chain that form the list. 

Each node can contain any number number of data fields, but only contains one pointer that always points to the next node in the list. This means that each node in a single linked list only knows about its successor and nothing of its predecessor. 



Figure 1 - Single Linked List Structure.


Monday, April 14, 2014

Linked Structures and Pointers

Linked structures and pointers are essentially containers that give us a way to store items in memory. Whilst linked structures provide the same functionality as an array (search, insertion and deletion), they are quite different in terms of its data structure, how the items are connected together and how the various operations (search, insertion and deletion) are performed.

To generalise, a linked structure contains the following -
  1. Item - The item that is to be stored in this structure.
  2. Pointer - A pointer to the next structure.