Compare to strings given as linked list
In C language, string library has a function strcmp that takes two arguments and return -1, 0 or 1 depending on whether first string is less than equal-to or greater than the second string. int strcmp(const char *str1, const char *str2); Write similar function that compare strings given in the form of linked list, For […]
Reversing a doubly linked list
Given a doubly linked list. Write a function to reverse it. If given list is then output of our function should be
Increment a number given in the form of linked list
Given a large number represented in the form of a linked list, Write code to increment the number in-place. For example:
Fix loop in a sorted linked list
Given a Sorted linked list which has a loop (link pointer of last node is not NULL and points to some other node). Fix the link of last node (i.e make it NULL).
Singly linked list implementation of Queue
In a general Queue (at any office or bank or any other place), people join the queue at the end and are removed from the front of queue. Similarly Queue data structure is a linear list of elements where element is always inserted at the end and deleted from the front.
Inserting in a linked list
Given a Singly linked list. Write functions to insert at different positions in the list: At start of the linked list. At end of the linked list. After k nodes from the start of list. After k nodes from the end of linked list. Insert in a sorted linked list.
Linked List Implementation of Stack in C++
Write a class which will implement the Stack data structure in C++. Give the declaration & definition of the class. Also define the Node. For simplicity, you may assume stack to hold integer data type.
Sorting a linked list
Write a function to sort the given unsorted linked list. Input list: 6 -> 7 -> 0 -> 1 -> 8 -> 2 -> 4 -> 3 Output list: 0 -> 1 -> 2 -> 3 -> 4 -> 6 -> 7 -> 8
Sorting a linked list of 0s, 1s and 2s
Given a Singly linked list with each node containing either 0, 1 or 2. Write code to sort the list. Input List: 1 -> 1 -> 2 -> 0 -> 2 -> 0 -> 1 -> 0 Output : 0 -> 0 -> 0 -> 1 -> 1 -> 1 -> 2 -> 2
Rotating a linked list around pivot
We have seen a question to rotate an array around a pivot earlier. Now write similar code for linked list. Given a linked list and an integer value ‘k’. Write a code to rotate linked list by k nodes from the end, as shown in the below diagram for k=2 Note that k nodes are counted […]