Linked List: Interview Questions and Practice Problems

Linked List: Interview Questions and Practice Problems

A linked list is a linear data structure consisting of a group of nodes where each node point to the next node by means of a pointer. Each node is composed of data and a reference (in other words, a link) to the next node in the sequence.

Image for post

Linked lists are among the simplest and most common data structures. The principal benefits of a linked list over a conventional array are –

  • The list elements can easily be inserted or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory, while an array has to be declared in the source code, before compiling and running the program.
  • Linked lists allow insertion and removal of nodes at any point in the list, and can do so with a constant number of operations if the link previous to the link being added or removed is maintained during list traversal.

On the other hand, simple linked lists by themselves do not allow random access to the data, or any form of efficient indexing. Thus, many basic operations ? such as obtaining the last node of the list, or finding a node that contains a given data, or locating the place where a new node should be inserted ? may require sequential scanning of most or all of the list elements.

In this post, we have list out commonly asked interview questions that uses linked list data structure-

  1. Introduction to Linked Lists
  2. Linked List Implementation | Part 1
  3. Linked List Implementation | Part 2
  4. Static Linked List in C
  5. Clone given Linked List
  6. Delete Linked List
  7. Pop operation in linked list
  8. Insert given node into the correct sorted position in the given sorted linked list
  9. Given a linked list, change it to be in sorted order
  10. Split the nodes of the given linked list into front and back halves
  11. Remove duplicates from a sorted linked list
  12. Move front node of the given list to the front of the another list
  13. Move even nodes to the end of the list in reverse order
  14. Split given linked list into two lists where each list containing alternating elements from it
  15. Construct a linked list by merging alternate nodes of two given lists
  16. Merge given sorted linked lists into one
  17. Merge Sort Algorithm for Singly Linked List
  18. Intersection of two given sorted linked lists
  19. Reverse linked list | Part 1 (Iterative Solution)
  20. Reverse linked list | Part 2 (Recursive Solution)
  21. Reverse every group of k nodes in given linked list
  22. Find K?th node from the end in a linked list
  23. Merge alternate nodes of two linked lists into the first list
  24. Merge two sorted linked lists from their end
  25. Delete every N nodes in a linked list after skipping M nodes
  26. Rearrange linked list in specific manner in linear time
  27. Check if linked list is palindrome or not
  28. Move last node to front in a given Linked List
  29. Rearrange the linked list in specific manner
  30. Detect Cycle in a linked list (Floyd?s Cycle Detection Algorithm)
  31. Sort linked list containing 0?s, 1?s and 2?s
  32. Stack Implementation using Linked List
  33. Queue Implementation using Linked List
  34. Remove duplicates from a linked list
  35. Rearrange the linked list so that it has alternating high, low values
  36. Rearrange a Linked List by Separating Odd Nodes from the Even Ones
  37. Calculate height of a binary tree with leaf nodes forming a circular doubly linked list
  38. XOR Linked List: Overview and Implementation
  39. Convert a multilevel linked list to a singly linked list

Thank you.

15