Must Need driver file..use the given cpp and header files only
And solve this graph problems...need graph cpp and header also after change.
If I get correct answer I will upvote you.
quetype.h #ifndef QUETYPE_H_INCLUDED #define QUETYPE_H_INCLUDED class FullQueue {}; class EmptyQueue {}; template class QueType { struct NodeType { ItemType info; NodeType* next; }; public: QueType(); ~QueType(); void MakeEmpty(); void Enqueue(ItemType); void Dequeue(ItemType&); bool IsEmpty(); bool IsFull(); private: NodeType *front, *rear; }; #endif // QUETYPE_H_INCLUDED quetype.cpp #include "quetype.h" #include using namespace std; template QueType::QueType() { front = NULL; rear = NULL; } template bool QueType::IsEmpty() { return (front == NULL); } template bool QueType::IsFull() { NodeType* location; try { location = new NodeType; delete location; return false; } catch(bad_alloc& exception) { return true; } } template void QueType::Enqueue(ItemType newItem) { if (IsFull()) throw FullQueue(); else { NodeType* newNode; newNode = new NodeType; newNode->info = newItem; newNode->next = NULL; if (rear == NULL) front = newNode; else rear->next = newNode; rear = newNode; } } template void QueType::Dequeue(ItemType& item) { if (IsEmpty()) throw EmptyQueue(); else { NodeType* tempPtr; tempPtr = front; item = front->info; front = front->next; if (front == NULL) rear = NULL; delete tempPtr; } } template void QueType::MakeEmpty() { NodeType* tempPtr; while (front != NULL) { tempPtr = front; front = front->next; delete tempPtr; } rear = NULL; } template QueType::~QueType() { MakeEmpty(); }
#ifndef STACKTYPE_H_INCLUDED #define STACKTYPE_H_INCLUDED class FullStack {}; class EmptyStack {}; template class StackType { struct NodeType { ItemType info; NodeType* next; }; public: StackType(); ~StackType(); void Push(ItemType); void Pop(); ItemType Top(); bool IsEmpty(); bool IsFull(); private: NodeType* topPtr; }; #endif // STACKTYPE_H_INCLUDED stacktype.cpp #include #include "stacktype.h" using namespace std; template StackType::StackType() { topPtr = NULL; } template bool StackType::IsEmpty() { return (topPtr == NULL); } template ItemType StackType::Top() { if (IsEmpty()) throw EmptyStack(); else return topPtr->info; } template bool StackType::IsFull() { NodeType* location; try { location = new NodeType; delete location; return false; } catch(bad_alloc& exception) { return true; } } template void StackType::Push(ItemType newItem) { if (IsFull()) throw FullStack(); else { NodeType* location; location = new NodeType; location->info = newItem; location->next = topPtr; topPtr = location; } } template void StackType::Pop() { if (IsEmpty()) throw EmptyStack(); else { NodeType* tempPtr; tempPtr = topPtr; topPtr = topPtr->next; delete tempPtr; } } template StackType::~StackType() { NodeType* tempPtr; while (topPtr != NULL) { tempPtr = topPtr; topPtr = topPtr->next; delete tempPtr; } }
Must Need driver file..use the given cpp and header files only
And solve this graph problems...need graph cpp and header also after change.
CSE225L - Data Structures and Algorithms Lab Lab 15 Graph In today's lab we will design and implement the Graph ADT. Now generate the Driver file (main.cpp) where you perform the following tasks