✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
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 ...
Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!