public static void SortStack(LinkedListStack stack) { int temp; if (stack.Size() > 0) { temp = stack.Pop(); SortStack(stack); SortedInsert(stack, temp); } }
public static void SortedInsert(LinkedListStack stack, int value) { if (stack.Size() == 0 || value > stack.Peek()) { stack.Push(value); } else { var temp = stack.Pop(); SortedInsert(stack, value); stack.Push(temp); } }
public static void ReversStack(LinkedListStack stack) { if (stack.Size() == 0) { return; } else { var temp = stack.Pop(); ReversStack(stack); stack.InsertAtBottom(temp); } }
public QueueUsingStack() { stack1 = new LinkedListStack(); stack2 = new LinkedListStack(); }