how to come up with a code to class queue and circular queue

Recommended Answers

All 2 Replies

Make an effort and post your code here. We don't do your homework for you.

As Rubberman says, you need to do the actual work; we can only advise you and help you fix problems. That having been said, I will give you this advice:

A Queue is a specialized for of collection in which the order that items are added is the same as the order they get removed. It is also called a FIFO (first in, first out) list. They can be easily implemented as either an array (for a fixed-size queue) or a list. The assignment probably assumes a list implementation, but if there is a limit to the size, you would be better off using an array.

Basically, the Queue is a list with both a pointer to the first item and a pointer to the last item. When you add an item, you add it to the head; when you remove an item, you remove it from the tail. You need to make sure that the tail pointer is updated when an item is removed, but other than that, it is a very easy data structure to implement if you already know how to write a linked list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.