# Linked List

The structure of Node of a Binary Tree and Doubly linked list are same. struct Node { int data; Node* left; Node* right; } Structure of Node of a Binary Tree struct Node { int data; Node* previous; Node* next; } Structure of Node of a Doubly linked list If we treat […]

Given a linked list, write the non-recursive function to reverse the list. If Input list is 1 -> 2 -> 3 -> 4 -> 5 Then output should be 5 -> 4 -> 3 -> 2 -> 1 We have seen the recursive and non-recursive functions to reverse the list. In the non-recursive version, we take three […]

Write a recursive function that add 5 to the alternate nodes of the linked list. For example, if the list is 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 then the function should change the list to the below one 1 -> 7 -> […]

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 […]

Given a doubly linked list. Write a function to reverse it. If given list is then output of our function should be

Given a large number represented in the form of a linked list, Write code to increment the number in-place. For example:

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).

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.

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.

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.