Solved

queue questions??

Posted on 2000-04-27
2
208 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

821 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