C# console application

what is linear queue and circular queue.how can i define?
Who is Participating?
MudieConnect With a Mentor Commented:
A linear queue is merely a normal queue.
Queue myQueue = new Queue();

You can add items to the queue.

And you can remove items from the queue.

When you add an item to the queue it goes to the end of the line. Removing items from the queue removes the item at the start of the line.
Just like a bank window, it's first in first out FIFO. Thus now the queue contains only b as the dequeue command removed a. This is demonstrated in the following sample code:

            private void button1_Click(object sender, System.EventArgs e)
                  //instantiate myQueue
                  Queue myQueue = new Queue();

                  //add a and b to myQueue

                  //dequeue an item from myQueue, in this case item a

                  //show the first item in the queue
                  MessageBox.Show( Convert.ToString(myQueue.Peek()) );

Create a button and double click it, copy and past the above code over the buttons Click event.

For more information see MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemCollectionsQueueClassTopic.asp

There isn't a nice class to use for circular queues, you can make one via an array however. The following webpage talks about circular queues: http://people.cs.uct.ac.za/~bmerry/manual/structures/circular.html

In a nutshell it's an optimized type of queue as insertation and deletion are independent. It has a "head" and a "tale" and if the tale is before the head it wraps around, hence the name circular queue. The array being used as the circular queue has one more item then is needed inorder to differentiate between being full or empty. Insertation is done by inserting to the tail index then incrementing the tail and finally wrapping if needed. Deleting is done by deleting the element at the head index and then incrimenting the head.

C implimentation & delete algorithm: http://datastructures.itgo.com/staque/queues/circular/delete.htm
C implimentation & insert algorithm:

If you need more information let me know.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.