Question: Problem 2. (7 points) Complete the following function that reverses a singly linked list in-place given the head node of the list. Assume each node

Problem 2. (7 points) Complete the following function that reverses a singly linked list in-place given the head node of the list. Assume each node has a "next" pointer. Your algorithm should have O(n) time complexity where n is the number of nodes in the list and O(1) additional space complexity. reverse(head) Input: Head node of a singly-linked list Output: Return the head of the reversed list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
