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:
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...
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...
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...
PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please so I can understand LinkedList ADT: class myLinkedList: def __init__(self): self.__head = None self.__tail = None self.__size = 0 def insert(self, i, data): if self.isEmpty(): self.__head = listNode(data) self.__tail = self.__head elif i <= 0: self.__head = listNode(data, self.__head) elif i >= self.__size: self.__tail.setNext(listNode(data)) self.__tail = self.__tail.getNext() else: current = self.__getIthNode(i - 1) current.setNext(listNode(data,...
starter code To write a program using the starter code which is TestLinkedList to see if the LinkedList program has bugs. It will produce ether a pass or fail.More information is in the first two pictures. LinkedList.java /** * @author someone * * Implements a double-linked list with four errors */ public class LinkedList<E> { // The first and last nodes in the list private Node<E> head, tail; // Number of items stored in the list private int size; //...
PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment the lines please so I can understand. There are short and med files lengths for each the list of names/ids and then search id file. These are the input files: https://codeshare.io/aVQd46 https://codeshare.io/5M3XnR https://codeshare.io/2W684E https://codeshare.io/5RJwZ4 LinkedList ADT to store student records(code is below). Using LinkedList ADT instead of the Python List. You will need to use the Student ADT(code is below) Imports the Student class...
You are the systems manager for Blue City Movies Rentals and you have been asked to create a report on historical sales data. To complete your task you will combine and edit data from multiple sources using Excel’s Power add-ins, XML, and text functions.Instructions:For the purpose of grading the project you are required to perform the following tasks:StepInstructionsPoints Possible1Open e10c2MovieRentals.xlsx and save the workbook with the name e10c2MovieRentals_LastFirst.02Import the movie data from the delimited file e10c2Movies.txt and rename the new worksheet Inventory.Hint: On the Data tab,...
Using C programming language Question 1 a) through m) Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. a. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. b....
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...