✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
We have a Linked List called lst, and we want to reverse this linked list. That means after our code runs, we want lst.head to point to what's currently the last item in the list, and iterating on the links from there one by one would get us to the current head of the list. Finish the implementation given below to achieve this.
Your code doesn't need to have perfect formatting and syntax - the main point is to write down the idea behind the algorithm, not an executable code.
def reverse(lst):
current = lst.head
prev = None
while current is not None:
... insert your code here ...
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!