Question: 2. Write an iterative algorithm which takes an input a singly linked list and reverse it. Input: List A: 1->2->40->20->Null Output: List A: 20->40->2->1->Null

2. Write an iterative algorithm which takes an input a singly linked list and reverse it. Input: List A: 1->2->40->20->Null Output: List A: 20->40->2->1->Null Show the time complexity of your algorithm? Algorithm ReverseList(A) // operations on list // 1. Check if A is empty by comparing A = Null // 2. Next element of the list by A.next()
Step by Step Solution
3.38 Rating (148 Votes )
There are 3 Steps involved in it
Here is an iterative algorithm to reverse a singly linked list Algorith... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (2 attachments)
663dedd9f26c0_960969.pdf
180 KBs PDF File
663dedd9f26c0_960969.docx
120 KBs Word File
