Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

queue questions??

Posted on 2000-04-27
2
Medium Priority
?
226 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 40 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses

916 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