Sollicitatievraag bij Hughes Systique

Implement Queue using Stacks

Antwoord op sollicitatievraag

Anoniem

29 okt 2017

enQueue(q, x) 1) While stack1 is not empty, push everything from satck1 to stack2. 2) Push x to stack1 (assuming size of stacks is unlimited). 3) Push everything back to stack1. dnQueue(q) 1) If stack1 is empty then error 2) Pop an item from stack1 and return it

10