# Category Archives: Linked List

View algorithms on Linked Lists.

## Check whether the Linked List has an even length or odd?

Question: Given a Linked List, we need to find out if the number of nodes in the Link List are odd or even? Input: 4, 8, 15, 16, 23, 42 Output: EVEN The most easy method to solve this problem would be by traversing the entire Linked List and counting the number of nodes as we go. As… Read More »

## How will you print a Linked List in a reversed order.

Question: Print the Linked List in reverse order. The actual structure of the Linked List must remain intact. Input: 4, 8, 15, 16, 23, 42 Output: 42, 23, 16, 15, 8, 4 We just discussed how to reverse a Linked List in an older post. Reverse a singly Linked List. But, in the above described method we changed… Read More »

## 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 »

## Write a program to insert a node in a sorted Linked List

Question: Write a program to insert a node in a given sorted Linked List. Given List: 23 -> 32 -> 99 -> 101 -> 2222 Node to add:- 50 Output:- 23 -> 32 -> 50 -> 99 -> 101 -> 2222 To insert a node in a sorted Linked List, we need to perform a basic Linked List… 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 »