Posted on 2003-02-27
I am tring to build two queues , then pass the data between them using the enqueue and the dequeue.Now I know I will need to loop , and check to one for end of file,while the other must check that the queue (1)is Not empty.
this is where I am coming up with different solutions.
So here is what I came up with . Maybe you can help me to understand what the output would be.
1 Q1 = createQueue
2 Q2 = createQueue
3 loop ( not end of file ) this one I think should read
should read the data.
1 read number
2 enqueue (Q1 , number)
3 enqueue (Q2 , number)
4 loop (not empty Q1)
1 dequeue (Q1, x)
2 enqueue (Q2, x)
data to use = 5,7,12,4,0,4,6
I think the Not ( logical ) is throwing me off. the first loop should read the data into both Queues. The second loop as long as the as Q1 is not empty do loop.
But I never get the same answer twice.
I hope you can help me , thank you