100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Other

Lecture 6 Extra Credit Data Structures Queue

Rating
-
Sold
-
Pages
4
Uploaded on
06-11-2025
Written in
2025/2026

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'.

Show more Read less








Whoops! We can’t load your doc right now. Try again or contact support.

Document information

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

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;
}
};
-----------------------------------------------------------------------------
$15.49
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
tinahuynh

Get to know the seller

Seller avatar
tinahuynh California State University, Long Beach
View profile
Follow You need to be logged in order to follow users or courses
Sold
New on Stuvia
Member since
1 month
Number of followers
0
Documents
68
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

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

Frequently asked questions