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 »
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 »
Given a singly linked list and a position, delete a linked list node at the given position.
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 »
Given a singly linked list L0 -> L1 -> … -> Ln-1 -> Ln. Rearrange the nodes in the list so that the new formed… Read More »
Given a Linked List. The Linked List is in alternating ascending and descending orders. Sort the list efficiently.
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 »
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 »
Given a doubly linked list, write a function to sort the doubly linked list in increasing order using merge sort.
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 »
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 »
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 »
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 »
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 »