Пример #1
0
    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);
    }
Пример #2
0
    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);
    }