PROBLEM:
string CBQueue::dequeue( )
This method should remove and return the item at the front of the queue- please add comments
EXISTING CODE:
#include // this allows you to declare and use strings
#include
using namespace std;
struct qNode
{
string data;
qNode* next;
qNode* prev;
};
class CBQueue
{
public:
CBQueue();
int CBQueue::getSize( );
bool CBQueue::isEmpty( );
private:
qNode* front;
qNode* rear;
int size;
};
#include "CBQueue.h"
CBQueue::CBQueue()
{
front = NULL;
rear = NULL;
size = 0;
}
//Returns elements in CBQuene
int CBQueue::getSize( ){
return size;
}
//return whether the queue is empty or not
bool CBQueue::isEmpty( ){
if(front == NULL)}{
return true;
}
else{
return false;
}
//
void CBQueue::enqueue(string s){
//Create a structure of Node which will hold the data s
struct qNode * temp = (struct qNode *)malloc(sizeof(struct qNode));
//data assigned as s
temp->data = s;
//initially prevIOUS pointer is NULL
temp->prev = NULL;
//initially next pointer is NULL
temp->next = NULL;
//If it is the first NODE
if (front == NULL)
{
//THEN FRONT AS REAR IS ASSIGNED AS TEMP
front = rear = temp;
}
else
{
//Otherwise add the new node to the rear end
rear->next = temp;
//Make temp previous as rear
temp->prev = rear;
//Now the temp becomes the rear
rear = temp;
}
//
void CBQuelue::printF2B( ){
temp = front;
//check if quene is empty
if ((front == NULL) && (rear == NULL)) {
cout<<"Queue is empty."<
return;
}
//if not empty-then print the items of the quene starting at the front and proceed to the rear
cout<<"Queue elements are (Front to Rear): ";
while (temp != NULL) { //while(temp)?
cout
temp = temp->next;
}
cout<
}
string CBQueue::dequeue( ){
}
string CBQueue::dequeue( ){
// if the queue is empty
if( this->front == NULL )
return "";
// if the queue is not empty
else
{
// store the front element in the beginning of the queue
string x = this->front->data;
// make second node as the new front node
this->front = this->front->next;
// delete the previous front node
delete this->front->prev;
this->front->prev = NULL;
return x;
}
}
PROBLEM: string CBQueue::dequeue( ) This method should remove and return the item at the front of...
PROBLEM- void CBQueue::printF2B( ) If the queue is empty, the method should print “Queue is empty”, otherwise, this method should print the items in the queue starting at the front of the queue and proceeding to the rear of the queue. The items should be printed one per line. Now that this method is written, you can do a more thorough job of testing enqueue( ). You will want to call printF2B( ) and printB2F( ) after implementing each method...
How do I pass values to this function? class DynIntQueue { struct QueueNode { int value; QueueNode *next; QueueNode(int value1, QueueNode *next1 = nullptr) { value = value1; next = next1; } }; // These track the front and rear of the queue QueueNode *front; QueueNode *rear; public: // Constructor and Destructor DynIntQueue(); ~DynIntQueue(); // Member functions void enqueue(int); void dequeue(int &); bool isEmpty() const; void clear(); }; main #include <iostream> #include "DynIntQueue.h" using namespace std; int main() {DynIntQueue list;...
Are based on the following Queue class code segment class QueueFull {/* Empty exception class */}; Class Queue Empty {/* Empty exception class */}; struct Node//Node structure int data;//Holds an integer Node* next;//Pointer to next node in the queue}; Class Queue//Linked node implementation of Queue ADT {Private: Node* front;//Pointer to front node of queue Node* rear;//pointer to last node of queue Public: Queue ()://default constructor initializes queue to be empty -Queue ();//Deallocates all nodes in the queue Void Add (int...
Hello, I have some errors in my C++ code when I try to debug it.
I tried to follow the requirements stated below:
Code:
// Linked.h
#ifndef INTLINKEDQUEUE
#define INTLINKEDQUEUE
#include <iostream>
usingnamespace std;
class IntLinkedQueue
{
private: struct Node {
int data;
Node *next;
};
Node *front; // -> first item
Node *rear; // -> last item
Node *p; // traversal position
Node *pp ; // previous position
int size; // number of elements in the queue
public:
IntLinkedQueue();...
To solve real world problem, the programer uses ADT like list, stack, queue, set, map, ... etc. to build our data model. In AS8, we pick and choose STL queue and stack to build a postfix calculator. In this assignment you are to Design your own linked-list, a series of integer nodes. The private attributes of this IntLinked Queue including a integer node struct and private control variables and methods: private: struct Node { int data; Node *next; }; Node...
Code in C++. Can someone make it so that the code below can be compiled? ▪ Creating an empty queue ▪ Inserting a value ▪ Removing a value ▪ Finding the size of the queue ▪ Printing the contents of the queue ▪ Adding the contents of one queue to the end of another ▪ Merging the contents of two queues into a third, new, queue Class Attributes Your class should be implemented using a linked list and should have...
Write a function that takes a string parameter and determines whether the string contains matching grouping symbols. Grouping symbols are parenthesis ( ) , brackets [] and curly braces { }. For example, the string {a(b+ac)d[xy]g} and kab*cd contain matching grouping symbols. However, the strings ac)cd(e(k, xy{za(dx)k, and {a(b+ac}d) do not contain matching grouping symbols. (Note: open and closed grouping symbols have to match both in number and in the order they occur in the string). Your function must use...
Raphael was very happy last week until his boss suddenly called him yesterday, asking him to rewrite his code. Despite being terribly upset about it, he has finished up writing part of the code below. However, same as his predicament from last week, he doesn't understand how to complete the code to include functions for a) searching for a person and b) deleting the person at the front. Please help him complete his .cpp file ABOVE by defining the two...
HI USING C++ CAN YOU PLEASE PROGRAM THIS ASSIGNMENT AND ADD
COMMENTS:
stackARRAY:
#include<iostream>
#define SIZE 100
#define NO_ELEMENT -999999
using namespace std;
class Stack {
int arr[SIZE]; // array to store Stack elements
int top;
public:
Stack() {
top = -1;
}
void push(int); // push an element into Stack
int pop(); // pop the top element from Stack
int topElement(); // get the top element
void display(); // display Stack elements from top to bottom
};
void Stack...
I need help fixing my code. My output should be the following. Hello, world! : false A dog, a panic in a pagoda : true A dog, a plan, a canal, pagoda : true Aman, a plan, a canal--Panama! : true civic : true If I had a hi-fi : true Do geese see God? : true Madam, I’m Adam. : true Madam, in Eden, I’m Adam. : true Neil, a trap! Sid is part alien! : true Never odd...