Header Ads

[DSA] Exercises for circular linked list



Here are some exercises for you to practice about circular linked list:

  1. Write a function to find the middle node of a circular linked list. If there are two middle nodes, return the second middle node.
  2. Write a function to check if a circular linked list is palindrome.
  3. Write a function to find the node at the beginning of a loop in a circular linked list.
  4. Write a function to split a circular linked list into two halves.
  5. Write a function to check if two circular linked lists are identical.
  6. Write a function to rotate a circular linked list by k nodes.
  7. Write a function to reverse a circular linked list.
  8. Write a function to find the sum of two circular linked lists.
  9. Write a function to remove duplicates from a circular linked list.
  10. Write a function to insert a node in a sorted circular linked list.
  11. Write a function to delete every nth node in a circular linked list.
  12. Write a function to merge two sorted circular linked lists.
  13. Write a function to insert a node at the end of a circular linked list.
  14. Write a function to reverse every k nodes in a circular linked list.
  15. Write a function to find the largest element in a circular linked list.
  16. Write a function to find the smallest element in a circular linked list.
  17. Write a function to delete a node with a given value from a circular linked list.
  18. Write a function to check if a circular linked list contains a loop.
  19. Write a function to remove the last node from a circular linked list.
  20. Write a function to add two circular linked lists of different lengths.
  21. Write a function to check if a circular linked list is sorted in ascending order.
  22. Write a function to check if a circular linked list is sorted in descending order.
  23. Write a function to find the length of a circular linked list.
  24. Write a function to delete all nodes with even values in a circular linked list.
  25. Write a function to delete all nodes with odd values in a circular linked list.
  26. Write a function to find the second largest element in a circular linked list.
  27. Write a function to find the second smallest element in a circular linked list.
  28. Write a function to find the sum of all nodes in a circular linked list.
  29. Write a function to find the product of all nodes in a circular linked list.
  30. Write a function to insert a node at a given position in a circular linked list.
  31. Write a function to find the difference between the sum of nodes at odd positions and the sum of nodes at even positions in a circular linked list.
  32. Write a function to insert a node in a sorted circular linked list in such a way that the resulting list remains sorted.
  33. Write a function to remove all occurrences of a given value from a circular linked list.
  34. Write a function to find the maximum difference between two consecutive elements in a circular linked list.
  35. Write a function to reverse a circular linked list using recursion.
  36. Write a function to sort a circular linked list in ascending order.
  37. Write a function to sort a circular linked list in descending order.
  38. Write a function to find the median of a circular linked list.
  39. Write a function to split a circular linked list into two halves at the midpoint.
  40. Write a function to find the kth smallest element in a circular linked list.
  41. Write a function to move the last node to the front of a circular linked list.
  42. Write a function to move the first node to the end of a circular linked list.
  43. Write a function to swap the first and last nodes of a circular linked list.
  44. Write a function to check if a circular linked list is a palindrome.
  45. Write a function to remove duplicate nodes from a sorted circular linked list.
  46. Write a function to split a circular linked list into two halves based on the sum of nodes in each half.
  47. Write a function to find the node at the beginning of a loop in a circular linked list.
  48. Write a function to rotate a circular linked list by k nodes.
  49. Write a function to convert a circular linked list to a singly linked list.
  50. Write a function to find the length of the longest palindrome in a circular linked list. 
  51. Write a function to find the smallest window in a circular linked list that contains all the elements of a given set.
  52. Write a function to flatten a circular linked list that contains nested lists (each node in the list can be a value or a list).
  53. Write a function to find the largest sum subarray in a circular linked list.
  54. Write a function to remove the last n nodes from a circular linked list.
  55. Write a function to find the largest node in a circular linked list.
  56. Write a function to find the smallest node in a circular linked list.
  57. Write a function to merge two sorted circular linked lists into a single sorted circular linked list.
  58. Write a function to find the longest path in a circular linked list with weighted edges.
  59. Write a function to count the number of times a given value appears in a circular linked list.
  60. Write a function to check if a circular linked list is sorted in non-decreasing order.

Source: chatGPT

Không có nhận xét nào

Được tạo bởi Blogger.