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 »
We have already discussed 2 different ways to clone a linked list. In this post, one more simple method to clone a linked list is… Read More »
Given a linked list of co-ordinates where adjacent points either form a vertical line or a horizontal line. Delete points from the linked list which… Read More »
Given two sorted linked lists, construct a linked list that contains maximum sum path from start to end. The result list may contain nodes from… Read More »
Given a singly linked list, delete all occurrences of a given key in it. For example, consider the following list.
It doesn’t look possible to reverse a simple singly linked list. A simple singly linked list can only be reversed in O(n) time using recursive… Read More »
In general, array is considered a data structure for which size is fixed at the compile time and array memory is allocated either from Data… Read More »
We have discussed Linked List Introduction and Linked List Insertion in previous posts on singly linked list.