using arrays as stacks and queues