Solved

queue questions??

Posted on 2000-04-27
2
196 Views
Last Modified: 2010-04-02
what do the initially empty queues Q and T look like after the following sequence of statements? Q.QueueInsert(1,Success); Q.QueueInsert(2,Success); T.QueueInsert(3,Success); T.QueueInsert(4,Success); Q.GetQueueFront(QueueFront,Success); T.QueueInsert(QueueFront,Success); Q.QueueDelete(Success); T.QueueInsert(5,Success); Q.QueueInsert(6,Success);

after working on this i believe the answer is Q=1,2,6;T=3,4,5
am i right on this?
0
Comment
Question by:beachbumm
2 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 10 total points
ID: 2755570
Morning!

I assume that QueueInsert inserts the first argument at the "end" of the queue, GetQueueFront returns the "front" element without changing the queue, and that QueueFront is the variable in which that element was returned, and that QueueDelete removes the "front" element. Then we get:

Q:
T:

Q.QueueInsert(1,success);
Q.QueueInsert(2,success);

Q:  1, 2
T:

T.QueueInsert(3,success);
T.QueueInsert(4,success);

Q: 1, 2
T: 3, 4

Q.GetQueueFront(QueueFront,success);

Q: 1, 2
T: 3, 4
and QueueFront is 1

T.QueueInsert(QueueFront,success);

Q: 1, 2
T: 3, 4, 1

Q.QueueDelete(success);

Q: 2
T: 3, 4, 1

T.QueueInsert(5,success);
Q.QueueInsert(6,success);

Q: 2, 6
T: 3, 4, 1, 5

That differs somewhat from your answers, and the difference looks like it is connected to the interpretation of what Q.GetQueueFront(QueueFront,success); does. What do you think?
0
 

Author Comment

by:beachbumm
ID: 2755656
after working more on this i did come up with the same solution as you did. thanks!
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now