C++ Deque. Do not copy from other sites, I will check. Full points only for 100%
ID: 3561473 • Letter: C
Question
C++ Deque. Do not copy from other sites, I will check. Full points only for 100% completion.
Assignment https://www.sendspace.com/file/t7svuh
Assignment Files https://www.sendspace.com/file/1xy5bb
Tutor Psuedo Code https://www.sendspace.com/file/ssbqmb
I need help in regards to the files and completing them. Instructions are in the first link, ALL relevant files needed for program are in the second link. The third link is what a tutor helped me with in psuedo code, and can be switched out with the Deque.h within the Assignment Files if it's better.
Explanation / Answer
#include using namespace std; template class Node{ public: Node(); Node(T item):next(NULL),prev(NULL),data(item){ } ~Node(){ prev = next = NULL; } T data; Node *next; Node *prev; }; class DequeEmptyException{ public: DequeEmptyException(){ cout next; front->prev = NULL; } else{ front = NULL; } count--; delete tmp; tmp = NULL; return retVal; } template int Deque::AddBack(const T element){ Node *newNode = new Node(element); if(IsEmpty()){ front = rear = newNode; ++count; return 0; } // append to the list rear->next = newNode; newNode->prev = rear; rear = newNode; count++; } template T Deque::RemoveBack(){ if(IsEmpty()){ throw new DequeEmptyException(); } T retVal = rear->data; // delete the back node Node *tmp = rear; if( rear->prev != NULL){ rear = rear->prev; rear->next = NULL; } else{ rear = NULL; } count--; delete tmp; tmp = NULL; return retVal; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.