Write an algorithm for printing a singly linked list in reverse, using only constant extra space. This instruction implies that you cannot use recursion, but you may assume that your algorithm is a list member function.

Respuesta :

Answer:

- Loop through the list

- pop each item in the list

- unshift the popped items to the same list

- print the new list.

Explanation:

The algorithm above can be replaced with the reverse method in JavaScript and Python like,

My_list.reverse()

ACCESS MORE
EDU ACCESS