Space complexity to print reverse of linked list | Sololearn: Learn to code for FREE!

0

Space complexity to print reverse of linked list

Hi Please refer below code: It just prints linked list in proper order, in reverse order using stack and in reverse order using recursion. I am aware that all three of them has time complexity as O(n). Also stack usage makes space complexity as O(n)... However, does last option i.e. reverse using recursion not have space complexity as O(1)? https://code.sololearn.com/c83psZPyIS6z/?ref=app

8/31/2021 12:28:13 PM

Ketan Lalcheta

1 Answer

New Answer