Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

queue questions??

Posted on 2000-04-27
2
Medium Priority
?
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

715 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