You will make a program to run a tournament. The tournament will use abstract data types (i.e. a stack and a queue) that you create.   
You will use a linked linear structure to store the values and provide the necessary functions to interact with that linked structure. Data for both is a character.   You will have functions that implement the functions for each as indicated below.

You will use necessary pointer variable(s) to the element/node that is at the beginning of the structure, the end of the structure, or both as appropriate. You will not use a pointer other individual elements of the structure. In both cases removing a node is restricted to just one end; either the first or the last.   

Each data structure will be in a separate source file, with the declarations for each in a separate header file. Your tournament program will have separate source and header files.


The stack is a first in last out structure. You add to the top and can only look at or take off the top. You only need a singly linked list to implement it. Why is that? You will implement these functions, with appropriate parameters:

void push() // puts on item onto the structure int peek()    // returns the value on top of the structure void pop()    // removes the top item in the structure isEmpty()   


The queue is a first in first out structure. You add to the back and can only look at or take off the front. For the queue sit down with pencil and paper and study the required pointer manipulations. You only have the link(s) in each node, a pointer to the front and a pointer to the back. You can use a singly linked structure if you want. Have your pointer algorithms written out before you start writing your code! You will implement these functions, with appropriate parameters:   

void addBack()       // puts on item at the end of the structure int getFront()       // returns the value at the front of the structure
void removeFront() // removes the first item in the structure isEmpty():   


For the competition you will prompt the user for the number of players on each side. The user will enter all the players for one side (remember the ‘names’ are simple characters), then enter the list for the other side. Each player will be put in a lineup. Will the lineup be a queue or a stack? After each round the winner will go to the end of their line and the loser will be put on a loser pile. Is the loser pile a queue or a stack?   

Each round will take the front of each line. You will make a random draw. The loser goes in the loser pile, the winner returns to their line. For the random draw, you design it. Do you use a random draw for each player? Do you make a single random draw?   

The competition ends when there is only one player remaining. What do you do when one side has 2 or more players remaining and the other side has none? Remember to keep it simple! You will display the 1st, 2nd, and 3rd place finishers as well as which side won. How do you know the order? Create and describe whatever system you use to determine the winning team.   

This is a programming assignment and not a complete game! Other than entering the lineup the players just wait for the results. They should take no further actions. Make sure you test your program! And document the testing in your reflections.   

What to submit in your zip file:   
Your source and header files that implement your queue
Your source and header files that implement your stack
Your source and header file that implement the tournament, including the main function
Your makefile
Your reflections, which can include your design document, which as usual discusses the design, assumptions you needed to make, the test plan, testing results, and changes necessary as a result.   

NOTE: Testing will be more involved. The reflections has more weight so you can provide a more detailed description of how you tested your program.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include "Queue.h"

void addBack(int data, Queue & q){
    Queue::Node * n = new Queue::Node;
    n->data = data;
    n->next = 0;
    if (q.head == 0) {
       q.head = n;
       q.tail = n;
    } else {
       q.tail->next = n;
       q.tail = n;

int getFront(Queue & q){
    if (isEmpty(q)) {
       return 0;
    return q.head->data;

void removeFront(Queue & q){
    if (!isEmpty(q)) {
       Queue::Node * n = q.head ;
       q.head = q.head->next;
       if (q.head == 0) {
            q.tail = 0;
       delete n;
       n = 0;

By purchasing this solution you'll be able to access the following files:

50% discount

$48.00 $24.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats