Category: Linked Lists

Linked Lists

Doubly Linked Lists

Doubly Linked Lists

The following are problems with singly linked lists: A singly linked list allows traversal of the list in only one direction. Deleting a node from a list requires keeping track of the previous node,...

Merging of Two Circular Lists

Merging of Two Circular Lists

You can merge two lists into one list. The following program merges two circular lists. In order to merge or concatenate the two non-empty circular lists pointed to by p and q, it is...

Circular Linked Lists

Circular Linked Lists

A circular list is a list in which the link field of the last node is made to point to the start/first node of the list, as shown in following Figure. In the case...

Representation of Sparse Matrices

Representation of Sparse Matrices

A matrix is a two-dimensional data object made of m rows and n columns, therefore having m ยด n values. When m=n, we call it a square matrix.   The most natural representation is...

Polynomial Representation

Polynomial Representation

One of the problems that a linked list can deal with is manipulation of symbolic polynomials. By symbolic, we mean that a polynomial is viewed as a list of coefficients and exponents. For example,...

Erasing a Linked List

Erasing a Linked List

Erasing a linked list involves traversing the list starting from the first node, freeing the storage allocated to the nodes, and then setting the pointer to the list to NULL. If p is a...

Counting nodes of a Linked List

Counting nodes of a Linked List

Counting the number of nodes of a singly linked list requires maintaining a counter that is initialized to 0 and incremented by 1 each time a node is encountered in the process of traversing...

Sorting and reversing a linked list

Sorting and reversing a linked list

To sort a linked list, first we traverse the list searching for the node with a minimum data value. Then we remove that node and append it to another list which is initially empty....

Linked List Concept

Linked List Concept

Introduction When dealing with many problems we need a dynamic list, dynamic in the sense that the size requirement need not be known at compile time. Thus, the list may grow or shrink during...