Programming Exercises

Exercise 1: Reverse a Linked List

Write a function to reverse a singly linked list in place. Ensure that the original structure of the list is modified.

 

Exercise 2: Remove Nth Node From End of List

Write a function to remove the nth node from the end of a linked list and return its head.

 

Exercise 3: Find the Middle of a Linked List

Write a function to find the middle node of a singly linked list. If the list contains an even number of nodes, return the second middle node.

 

Exercise 4: Remove Nth Node From End of List

Write a function to remove the nth node from the end of a singly linked list and return the head of the modified list. Assume n is always valid and does not exceed the length of the list.

 

Exercise 5: Merge Two Sorted Linked Lists

Write a method to merge two sorted singly linked lists into a single sorted linked list.