elements at the head of the list code fragment class nodestackwhich implements the stack interface using singly linked listwhose nodes are objects of class node from code fragment reversing an array using stack we can use stack to reverse the elements in an arraythereby producing nonrecursive algorithm for the array-reversal problem introduced in section the basic idea is simply to push all the elements of the array in order into stack