Category: Linked List


Implement Stack Using Linked List

Objective: Write an algorithm to implement Stack using Linked List. If you do not know about then for starters its abstract data type in which follows the principle of LIFO (Last-In-First-Out) which means the...


Reverse Alternative ‘k’ nodes in a Linked List.

Objective: Given a linked list and a number ‘k’, write an algorithm to reverse alternate ‘k’ nodes in the linked list. This problem was asked in the Microsoft and Amazon interviews. Example: Approach: Recursion...


Reverse a Linked List in groups of given size ‘K’

Objective: Given a linked list and integer ‘k’, write an algorithm to reverse the linked list in groups of size ‘k’. Example: Approach: Earlier we have seen how to reverse a linked list, solution...


Delete X Nodes After Y Nodes In a Linked List

Objective: Given a Linked List and x and y. Delete x number of nodes after y nodes from the start. Example: ->10->20->30->40->50->60->70->80->90->100->110->120 Deleted 4 Nodes after 5 Nodes ->10->20->30->40->50->100->110->120 Approach: We need two pointers....


Merge Sort in a Linked list

Objective: Given a Linked List, Sort it using merge sort. Example: ->9->3->4->2->5->1 Sorted List: ->1->2->3->4->5->9 Approach: Reference : Merge Sort in array As it Merge sort, we apply the same logic , Divide and...


In a Binary Tree, Create Linked Lists of all the nodes at each depth.

Objective: Given a Binary tree create Linked Lists of all the nodes at each depth , say if the tree has height k then create k linked lists. NOTE : This problem is very...

%d bloggers like this: