The language we are using in Data Structures is C++ right
now.
#include <iostream>
#define MAX 10
using namespace std;
class Deque
{
int front, rear, size;
int arr[MAX];
public:
Deque(int size)
{
this->size = size;
front = rear = -1;
}
bool isFull()
{
return ((front == 0 && rear == size-1)||front == rear+1);
}
bool isEmpty(){ return front == -1; }
void push(int data)
{
if(front == -1)
{
front = 0;
arr[++rear] = data;
}
else if(front != 0)
arr[--front] = data;
else
cout << "Overflow!\n\n";
}
void inject(int data)
{
if (isFull())
{
cout << "Overflow!\n\n";
return;
}
if (front == -1)
{
front++;
rear++;
}
else
rear = rear + 1;
arr[rear] = data;
}
int pop()
{
int res;
if(isEmpty())
{
cout << "Underflow!\n\n";
res = -1;
}
else
{
res = arr[front];
if(front == rear)
front = rear = -1;
else
front = front + 1;
}
return res;
}
int eject()
{
int res;
if(isEmpty())
{
cout << "Underflow!\n\n";
res = -1;
}
else
{
res = arr[rear];
if(front == rear)
front = rear = -1;
else
rear = rear - 1;
}
return res;
}
void show()
{
for(int i = front; i <= rear; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
};
int main()
{
Deque deque(5);
deque.push(17);
deque.inject(10);
deque.inject(23);
deque.inject(16);
cout << "Initial contents:\n";
deque.show();
cout << "\nDeleting from front:\n";
cout << "Item deleted = " << deque.pop() << endl;
cout << "\nContents after deleting:\n";
deque.show();
cout << "\nDeleting from rear:\n";
cout << "Item deleted = " << deque.eject() << endl;
cout << "\nContents after deleting:\n";
deque.show();
cout << "\nPushing an element at the front:\n";
deque.push(21);
cout << "Contents after pushing to the front:\n";
deque.show();
return 0;
}
************************************************************ SCREENSHOT ****************************************************
CODE SNIPPET SCREENSHOTS:
![main.cpp saved #include <iostream> #define MAX 10 using namespace std; class Deque int front, rear, size; int arr[MAX]; publi](http://img.homeworklib.com/questions/7539d420-988a-11ea-af62-7321b91d46fe.png?x-oss-process=image/resize,w_560)
![main.cpp 5 saved if(front == -1) front = 0; arr[++rear] = data; } else if(front != 0) arr[--front] = data; else cout << Over](http://img.homeworklib.com/questions/75b4e9e0-988a-11ea-bba9-fdb0e87d4d97.png?x-oss-process=image/resize,w_560)
![main.cpp 2 saved else rear = rear + 1; arr[rear] = data; int pop() int res; if(isEmpty()) cout << Underflow!\n\n; res = -1;](http://img.homeworklib.com/questions/762c02a0-988a-11ea-bc79-0ff38ba1fc5f.png?x-oss-process=image/resize,w_560)
![main.cpp 3 saved int eject() int res; if(isEmpty()) cout << Underflow!\n\n; res = -1; else res = arr[rear]; if(front == rea](http://img.homeworklib.com/questions/76aae660-988a-11ea-a5f7-b57ffd5a1919.png?x-oss-process=image/resize,w_560)

CONSOLE OUTPUT:

The language we are using in Data Structures is C++ right now. Assignment9-Apr 3 References A...
Template Dequeue Class (C++ )
In this assignment, we will use a given test menu for the
template Deque Class (a Linked List based Double Ended Queue,
Deque) that you have put together.
Starter
testDeque.cpp which contains:
Timer class holder (you need to go through the LearnCpp Ch15
and import it in)
Node class
Deque class specification (you need to fill out the
definition)
here is the testDeque.cpp code:
// C++ implementation of doubly linked list Deque doubly linked
list...
Template Deque Class (C++)
In this assignment, we will use a given test menu for the
template Deque Class (a Linked List based Double Ended Queue,
Deque) that you have put together.
Recommended Steps
testDeque.cpp :
// C++ implementation of doubly linked list Deque doubly linked
list
#include <bits/stdc++.h>
using namespace std;
class Timer {
// To replace with the full timer class definition
// inside this folder: LearnCpp9_18_timeSortArray.cpp
};
// Node of a doubly linked list
template<class T>
class...
Spanish Vocabulary Helper For this assignment, we are going to work with adding and removing data from arrays, linear search, and File I/O. In addition, you will learn to work with parallel arrays This program will assist an English-speaking user to build their vocabulary in Spanish This program will read a file containing a list of words in English and another containing the translation of those words in Spanish. The words and corresponding translations should to be stored in two...
Data Structures and Algorithm Analysis – Cop 3530 Module 3 – Programming Assignment This assignment will access your skills using C++ strings and dynamic arrays. After completing this assignment you will be able to do the following: (1) allocate memory dynamically, (2) implement a default constructor, (3) insert and remove an item from an unsorted dynamic array of strings, (4) use the string class member functions, (5) implement a copy constructor, (6) overload the assignment operator, (7) overload the insertion...
C++ Linked List Implementation Motivation As we discussed in class, the data structures that you use to implement your program can have a profound impact on it's overall performance. A poorly written program will often need much more RAM and CPU time then a well-written implementation. One of the most basic data structure questions revolves around the difference between an array and a linked list. After you finish this assignment you should have a firm understanding of their operation. Problem...
For milestone #1, we will start the CARIT site with three static HTML pages and a CSS file. Create a dedicated folder for this project. This folder should contain all related files in this project. The future milestones are cumulative and built directly on top of your prior work. Function/content requirements: A home page named “index.html”, which include these contents at least: Description of the center. You may reference the example sites. Latest news: use list tags; make up some...
c programming A linked list is a linear data structure that allows us to add and remove items from the list very quickly, by simply changing a few pointers. There are many different variations of linked lists. We have studied the doubly-linked, circular, with a dummy-header-node version of a linked list. In the class notes we studied several functions to manipulate a Linked List. For this assignment you must write the code for the following additional linked list functions: addFirst,...
Requirements Print a range Write a bag member function with two parameters. The two parameters are Items x and y. The function should write to the console all Items in the bag that are between the first occurrence of x and the first occurrence of y. You may assume that items can be compared for equality using ==. Use the following header for the function: void print_value_range(const Item& x, const Item& y); print_value_range can be interpreted in a number of...
RE-POSTED - Computer Science staff, I need this question
answered. It will determine a pass or a fail. Its very imortant
that this and the other questions posted are answered 100% Thank
you.
13 - Template C++ Advance
Please Only answer assignment if your code is 100%. When
pasteing your code use text so I may copy and paste into visual
studio. The code and questions must be answered 100% correct and
works. Thank you.
Programming Assignment
Convert the int...
Hello I need help with this program. Should programmed in C!
Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...