## Delete last occurrence of an item from linked list

Given a liked list and a key to be deleted. Delete last occurrence of key from linked. The list may have duplicates. Examples: Input: 1->2->3->5->2->10,… Read More »

In Java, LinkedList class implements the list interface. This class consists of the following methods : 1. boolean add(Object element) : It appends the element… Read More »

## Merge two sorted linked lists such that merged list is in reverse order

Given two linked lists sorted in increasing order. Merge them such a way that the result list is in decreasing order (reverse order). Examples: Input:… Read More »

## Delete a Linked List node at a given position

Given a singly linked list and a position, delete a linked list node at the given position.

## Compare two strings represented as linked lists

Given two linked lists, represented as linked lists (every character is a node in linked list). Write a function compare() that works similar to strcmp(),… Read More »

## Rearrange a given linked list in-place.

Given a singly linked list L0 -> L1 -> … -> Ln-1 -> Ln. Rearrange the nodes in the list so that the new formed… Read More »

## Sort a linked list that is sorted alternating ascending and descending orders?

Given a Linked List. The Linked List is in alternating ascending and descending orders. Sort the list efficiently.

## Select a Random Node from a Singly Linked List

Given a singly linked list, select a random node from linked list (the probability of picking a node should be 1/N if there are N… Read More »

## Insertion Sort for Singly Linked List

We have discussed Insertion Sort for arrays. In this article same for linked list is discussed. Below is simple insertion sort algorithm for linked list.… Read More »

## Merge Sort for Doubly Linked List

Given a doubly linked list, write a function to sort the doubly linked list in increasing order using merge sort.

## Point to next higher value node in a linked list with an arbitrary pointer

Given singly linked list with every node having an additional “arbitrary” pointer that currently points to NULL. Need to make the “arbitrary” pointer point to… Read More »

## Swap nodes in a linked list without swapping data

Given a linked list and two keys in it, swap nodes for two given keys. Nodes should be swapped by changing links. Swapping data of… Read More »

## Generic Linked List in C

Unlike C++ and Java, C doesn’t support generics. How to create a linked list in C that can be used for any data type? In… Read More »

## Search an element in a Linked List (Iterative and Recursive)

Write a C function that searches a given key ‘x’ in a given singly linked list. The function should return true if x is present… Read More »

## Find Length of a Linked List (Iterative and Recursive)

Write a C function to count number of nodes in a given singly linked list. For example, the function should return 5 for linked list… Read More »