Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 1 out of 4 pages
Other

Lecture 6 Extra Credit Data Structures Queue

Document preview thumbnail
Preview 1 out of 4 pages

The provided text is a C++ program that implements a basic queue functionality using a `Queue` class. The main features of the program include: 1. **Menu Interface**: Users are presented with a menu that allows them to enqueue (add), dequeue (remove), view the queue, or quit the application. 2. **Enqueue Operation**: Users can add an item to the queue as long as it is not full. If the queue is full, a message is displayed. 3. **Dequeue Operation**: Users can remove an item from the queue if it is not empty. If the queue is empty, a message indicates that no items can be dequeued. 4. **Display Queue**: Users can view the elements currently in the queue. The queue is displayed in a linked format, showing the elements followed by `- NULL`. 5. **Input Validation**: The program checks for valid inputs and handles cases where the user might enter an invalid command. The program loops until the user chooses to quit by entering 'Q'.

Content preview

// Attatched: Lecture 6 Extra Credit
//
// Queue.h
//
// Created by Tina Huynh on 2/8/18.
// Copyright © 2018 Tina Huynh. All rights reserved.
//
// CMPR 131 - Data Structures

#include <iostream>
using namespace std;

const int SIZE = 5;
double input;

class intQueue
{
private:
double numbers[SIZE];
int front;
int back;
public:
intQueue() { front = back = SIZE - 1 ; }
~intQueue() {}
void makeEmpty() { front = back = SIZE - 1; }
void enqueue(double input)
{
if(front == SIZE - 1)
front = 0;

back = ((back + 1) % SIZE);
numbers[back] = input;
}
void dequeue(double & input)
{
front = ((front + 1) % SIZE);
input = numbers[front];
}
bool isEmpty()
{
return (front == back);
}
bool isFull()
{
return ((back + 1) % SIZE == front);
}
void showQueue()
{
int i = front;

do {
cout << numbers[i] << " -> ";
i = ((i + 1) % SIZE);
} while(i != back);
cout << numbers[back] << " -> ";
cout << "NULL" << endl;
}
};
-----------------------------------------------------------------------------

Document information

Uploaded on
November 6, 2025
Number of pages
4
Written in
2025/2026
Type
Other
Person
Unknown
$15.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
68
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions