C# console application

Posted on 2005-04-28
Last Modified: 2012-06-21
what is linear queue and circular can i define?
Question by:beeravally
    1 Comment
    LVL 2

    Accepted Solution

    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:

    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:

    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:
    C implimentation & insert algorithm:

    If you need more information let me know.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it. The first step, was to retrieve the image from camera into Image object. So that it can be displayed or …
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 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

    18 Experts available now in Live!

    Get 1:1 Help Now