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

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

1 Expert Approved Answer
Step: 1 Unlock

Here is an iterative algorithm to reverse a singly linked list Algorith... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

663dedd9f26c0_960969.pdf

180 KBs PDF File

Word file Icon

663dedd9f26c0_960969.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!