Follow

@design_RG

Make Paper Great Again

This is me solving a stack and a queue problem on paper.

Do have a go at it if you're into Kiddy puzzles. (although circular arrays is a bit of a mind bender)

==================
Question
==================

We have a stack and queue, [-,-,4,3] and [-,-,2,1] respectively. When you pop off of the stack, it enqueues on to the queue, implemented as a circular array. (So pop(x) => both pop off the stack, and enqueue(x))

(Front of the queue is currently on 2, and back on 1. We queue on to the front, and remove from the back. Note: This pattern is different from question 2!!).

What will the stack and queue look like after:

pop()

push(4)

pop()

dequeue()

push(5)

push(6)

pop()

dequeue()

push(4)

pop()

dequeue()

=================

@jump_spider @Full_marx @design_RG @tek @kornel @namark @Raman @fahrni @mngrif @rodolpho @shibaprasad @Gomario @freemo

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves. A STEM-oriented instance.

An inclusive free speech instance.
All cultures and opinions welcome.
Explicit hate speech and harassment strictly forbidden.
We federate with all servers: we don't block any servers.