public static void Main(string[] args) { StackLL s = new StackLL(); s.Push(1); s.Push(2); s.Push(3); s.Print(); Console.WriteLine(s.Pop()); s.Print(); }
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); }