Give a \(\Theta(n)\)-time nonrecursive procedure that reverses a singly linked list of \(n\) elements. The procedure should use no more than constant storage beyond that needed for the list itself.
REVERSE-SINGLY-LINKED-LIST(x)
1 a = x.head
2 b = x.head.next
3 while b != NIL:
4 c = b.next
5 b.next = a
6 a = b
7 b = c
8 x.head = a