Skip to content

Category Archives: Linked List

Given a Singly Linked List, starting from the second node delete all alternate nodes of it. For example, if the given linked list is 1->2->3->4->5… Read More
Given two lists sorted in increasing order, create and return a new list representing the intersection of the two lists. The new list should be… Read More
Write a function to delete a given node in a doubly-linked list.  Example: Input: DLL = 2->45->3->1, Node = 45Output:  2->3->1 Input: DLL = 2->45->3->1,… Read More
Given a singly linked list, write a function to swap elements pairwise.  Input : 1->2->3->4->5->6->NULL Output : 2->1->4->3->6->5->NULL Input : 1->2->3->4->5->NULL Output : 2->1->4->3->5->NULL Input : 1->NULL Output… Read More
Write a function that moves the last node to the front in a given Singly Linked List. Examples: Input: 1->2->3->4->5Output: 5->1->2->3->4 Input: 3->8->1->5->7->12Output: 12->3->8->1->5->7  … Read More
Assume the structure of a Linked List node is as follows.  C++ struct Node {   int data;   struct Node *next; };   // This code… Read More
Original Linked List Result Linked List 1 Result Linked List 2 If there are odd number of nodes, then first list should contain one extra.… Read More
Given a Doubly Linked List, the task is to reverse the given Doubly Linked List. Example: Input: Output: Recommended Practice Reverse a Doubly Linked List… Read More
Given an unsorted list of nodes. The task is to remove duplicates from the list.  Examples: Input: linked list = 12->11->12->21->41->43->21 Output: 12->11->21->41->43. Explanation: Second occurrence o… Read More
Write a function that takes a list sorted in non-decreasing order and deletes any duplicate nodes from the list. The list should only be traversed… Read More
Given a linked list, print reverse of it using a recursive function. For example, if the given linked list is 1->2->3->4, then output should be… Read More
Write a GetNth() function that takes a linked list and an integer index and returns the data value stored in the node at that index… Read More
Write a GetNth() function that takes a linked list and an integer index and returns the data value stored in the node at that index… Read More
Write a GetNth() function that takes a linked list and an integer index and returns the data value stored in the node at that index… Read More
Write a GetNth() function that takes a linked list and an integer index and returns the data value stored in the node at that index… Read More