Sep 172013
 

We have seen how to implement Queue using a linked list and using Array as the base data structure.  The question here is that given two Stacks, say S1 and S2, and no other data structure, simulate the functionality of a Queue, hence use two stacks as the base data structure for a Queue.

i.e we should expose two functions enqueue and dequeue which will insert the element and return it in FIFO order (First In First Out). Continue reading »