linked-list

Sort a linked list using insertion sort Cover Image
Sort a linked list using insertion sort

We have given the head of a singly linked list, write a program to sort the list using insertion sort, and return the head of the sorted linked list.

Remove Nth Node from List End Cover Image
Remove Nth Node from List End

Write a program to remove the Nth node from the end of the linked list i.e. when the node is traversed from the end we have to delete the Nth node from there.

Least Frequently Used (LFU) Cache Implementation Cover Image
Least Frequently Used (LFU) Cache Implementation

The least frequently used (LFU) is a cache algorithm used to manage memory within a computer. In this method, the system keeps track of the number of times a block is referenced in memory, and when the cache is full, our system removes the item with the lowest reference frequency.

Implement Least Recently Used (LRU) Cache Cover Image
Implement Least Recently Used (LRU) Cache

The Least Recently Used (LRU) is one of the popular caching strategies, which defines the policy to discard the least recently used items first from the cache and make room for new elements when the cache is full. It is used to organize items in order of their use, which allows identifying items that have not been used for a long time.

Swap List Nodes in Pairs Cover Image
Swap List Nodes in Pairs

Given a singly linked list, write a program to swap every two adjacent nodes and return its head. If the number of nodes are odd, then we need to pair-wise swap all the elements except the last element.

Intersection of two sorted linked lists Cover Image
Intersection of two sorted linked lists

Given two sorted linked lists, write a program to find the intersections of the linked lists, and return the head of the new Linked List.

Find middle element in linked list Cover Image
Find middle element in linked list

Given a singly linked list, write a program to find the middle node of the linked list. If the node count is even then we need to return the second middle node.

Detect Loop in a Linked List Cover Image
Detect Loop in a Linked List

Write a program to detect the loop in a linked list. A linked list with a cycle causes iteration over the list to fail because the iteration will never reach the end of the list. Therefore, it is desirable to be able to detect that a linked list has no cycle before trying an iteration. So, we are going to discuss various algorithms to detect a loop in a singly linked list. This is also one of the best-linked list interview problems.

Reverse a linked list Cover Image
Reverse a linked list

Write a program to reverse a linked list. A head pointer of a linked list is given and our task to reverse the entire list so that when the resulted list is traversed it looks like we are traversing the original list from tail to head.

Our weekly newsletter

Subscribe to get weekly content on data structure and algorithms, machine learning, system design and oops.

© 2022 Code Algorithms Pvt. Ltd.

All rights reserved.