Using an ADT Linked List and the following code, how would I express the runtime in Big O Notation?:
def reverse (self):
(1)if self._head is not None:
(2)temp = self._head.item
(3)self._head = self._head.next
(4)self.reverse()
(5)self.append(temp)
My thought process: Lines 1 - 3 were essentially constant as they are just setting and getting items from the beginning of the Linked List, and line 5 is theta(n) by definition. Each time the list becomes smaller, so I thought the function runs n(n-1)(n-2).... implying that it is theta(n!). Could I get some help?