I have two queues Q1 , Q2 and I want to execute the contents into queue Q3. The queue are shown front ( left ) to rear ( right ).
Contents of Q1 and Q2
Q1: 42 30 41 31 19 20 25 14 10 11 12 15
Q2: 1 4 5 4 10 13
My algorithm I came up with is shown below ;
1 Q3 = createQueue
2 count = 0
3 loop ( not empty Q1 and not empty Q2)
1 count = count + 1
2 dequeue (Q1 , x )
3 dequeue (Q2 , y )
4 if ( y equal count )
1 enqueue (Q3 , x )
now I have tried several times with different solutions. I think the Not is confusing me. If you can help please show me how to work the problem to get the correct ans. of what the contents would be in Q3. I get the first number as 4 that stays ok but the rest never stay in the same position . also please explain the Not. It is a logical Not is it so. where, when if it becomes true it turns false? At least thats the way I read it in my C book.