Category Archives: Linked List

View algorithms on Linked Lists.

Reverse a singly Linked List.

Question: How will you reverse a singly Linked List? Input:– 4 -> 8 -> 15 -> 16 -> 23 -> 42 Output:– 42 -> 23 -> 16 -> 15 -> 8 -> 4 Reversing a singly Linked List is based upon a very simple concept. We just need to swap the “NEXT” value of each of the node,… Read More »

Find nth node from the end of a Linked List.

Question: Suppose you are given a Linked List as 45-> 123-> 87-> 11-> 53-> 24-> 412-> 22. And we have to find the nth node from the end. Input:- n = 3 Output:- 24 BRUTE FORCE APPROACH:- In this method, start with the first node and count how many nodes are there after that node. If the number… Read More »

Important operations on a Linked List

We covered some of the basic operations on a Linked List in this post. Basic operations on a Linked List However, in order to create a functional Linked List, we need even more operations before we can proceed further. Some of these operations are:- Inserting a node in the beginning of the Linked List. Inserting a node in… Read More »

Basic Operations on a Linked List

Here are some of the basic operations on a singly Linked List. Creating a new List Adding new elements Traversing a List Printing a List Basic functions to perform the above techniques have been defined in the code below. CREATING A NEW LIST A new Linked List creation means that we do not have any elements in the… Read More »

What is a Linked List?

Linked List is a data structure used for storing collections of data. Linked list has the following properties. Successive elements are connected by pointers. Last element points to NULL. Can grow or shrink in size during execution of a program. Can be made just as long as required (until free memory is available). It does not waste memory… Read More »