class Fifo Lifo enqueue new Lifo Lifo dequeue new Lifo public void Enq

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
class Fifo
{
Lifo enqueue = new Lifo();
Lifo dequeue = new Lifo();
public void Enqueue(int n)
{
while (!dequeue.IsEmpty()) enqueue.Push(dequeue.Pop());
enqueue.Push(n);
}
public int Dequeue()
{
while (!enqueue.IsEmpty()) dequeue.Push(enqueue.Pop());
return dequeue.Pop();
}
public bool IsEmpty()
{
return enqueue.IsEmpty() && dequeue.IsEmpty();
}
}