public static void reverseStack <T>(StackLL <T> stk, T elementToInsert) { if (stk.noOfElements == 0) { return; } T topObj = stk.Top(); stk.Pop(); reverseStack(stk); insertAtbottom(stk, topObj); }
public static void insertAtBottom <T>(StackLL <T> stk, T element) { if (stk.noOfElements == 0) { stk.Push(elementToInsert); return; } T topObj = stk.Top(); stk.Pop(); insertAtbottom(stk, element); stk.push(topObj); }