A question about 'queues'

Posted on 1998-10-27
Last Modified: 2010-04-16
I'm having some difficulty understanding the construction of
queues. The examples in my text are too long for me(4 pages) to gain a full understanding, which is resulting in confusion.

If someone could give me an example of how they are supposed
to be structured(the text has used different structures) along with an example I would greatly appreciate the help.

Also, if you could point me to some literature that explains the reason why pointers are used in some programs and not in other programs that involve queues, I would appreciate that as well.

Best regards,

Question by:Pyramid
  • 3

Accepted Solution

Raid earned 50 total points
ID: 1215864
Hello This is Raid:

Okay, you want to understand queues, right?
Well, I will show you an example of a queue, and then show
you my programming example, here they are:

Lets say we have names, and are queue can only fit five:

Now, we want to add a Ryan, so we would add Ryan to the top,
and have everything pushed down, but, since we only want
5 in are queue, we will have to discard the last one, which
in this case, it is Jason:


Notice, Jason is missing.  Anyway, I will show you how to program
it, now:

 crt, drivers;

 count: byte;
 queue: array[1 .. 5] of string;

procedure wait;
 keybutton: tevent;
 until keybutton.keycode <> kbNOKEY;

 { Define our people in our queue }
 queue[1] := 'George';
 queue[2] := 'Bob';
 queue[3] := 'Lisa';
 queue[4] := 'Micheal';
 queue[5] := 'Jason';
 { print it }
 for count := 1 to 5 do begin
  gotoxy(1, count); writeln(queue[count]);
 { now, we want to add Ryan }
 { so shift everything but the last one down, because
   the last one is going to be discarded anyway }
 { go from the bottom up so nothing gets overwritten }
 for count := 4 downto 1 do begin
  queue[count + 1] := queue[count];
 queue[1] := 'Ryan'; clrscr;
 { now print the new one }
 for count := 1 to 5 do begin
  gotoxy(1, count); writeln(queue[count]);
 { Simple as that }

Expert Comment

ID: 1215865
This is Raid:

Sorry to not include this, but about that "some people use
array's and some people use pointers" or something like that.
Well, pointers are used to point at things in memory(hence the name pointers), anyway, you can use arrays for this sort of thing you are dealing with, because they are easier to use.

Expert Comment

ID: 1215866
Sorry, Raid AGAIN!

About the part of your question about structers, you don't need any structers for this.  If you want structers(Types, or Records)
in that example then contact me at:

Author Comment

ID: 1215867
Thanks Raid,

That explains a few problems that I was having but I'll e-mail you the other questions I have.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to delete from listbox using edit box 6 292
Help with If Then Statement 8 323
Listen keywords are been pressed 3 332
websites monitor c++ or delphi 9 444
In this blog, I will share you some basic tips for content marketing and to rank your website on Google.
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

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

21 Experts available now in Live!

Get 1:1 Help Now