C++ - deals with list
Assginment given:

Consider a slight variation of the pointer-based implementation of the queue ADT. In this variation, the queue uses a circular linked list to represent the items in the queue. You must use only a single tail pointer. Construct the implementation of such queue ADT.

Your program should display the following menu to demonstrate the operations on queue objects for test run.

(1) Create queue object
(2) Enqueue
(3) Dequeue
(4) Display
(5) Exit
-------------------------------------------------------------------------

I think Question is rather vague please give me some suggestions on how u can do this..

thanks!

Recommended Answers

All 3 Replies

may i know how do i implement the circular linked list?
any codes to show

>may i know how do i implement the circular linked list?
Quick and dirty:

#include <iostream>

using namespace std;

struct node {
  int data;
  node *next;

  node ( int init, node *link )
    : data ( init ), next ( link )
  {}
};

int main()
{
  node *list = new node ( -1, 0 );
  node *it = list;

  list->next = list;

  for ( int i = 0; i < 10; i++ ) {
    it->next = new node ( i, list );
    it = it->next;
  }

  it = list->next;

  for ( int i = 0; i < 5; it = it->next ) {
    if ( it->data == -1 ) {
      cout<<endl;
      ++i;
    }
    else
      cout<< it->data <<"->";
  }
}

Please don't just blanketly post your homework assignments. We're not here to do your work for you. Post your own code, and we'll help you troubleshoot it. Additionally, we encourage members not to do your assignments for you, as they are contributing to you not learning anything.

We're here to help you learn, not to cheat.

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.