Solved

queue questions??

Posted on 2000-04-27
2
187 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
Comment Utility
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
Comment Utility
after working more on this i did come up with the same solution as you did. thanks!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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.
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.

771 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

15 Experts available now in Live!

Get 1:1 Help Now