
This is the source code for Stacks, but it has errors. Please update this without errors and warnings. And please provide the main function.
template<class T>
bool Stack<T>::isConsecutive(const T & data) const
{
size_t p = _top - 2;
cout<<(p+1>0)<<p<<endl;
for (size_t i = _top - 2; i + 1 > 0; i--) {
cout << elements[i]<<" "<<elements[i+1]<<endl;
if (elements[i] == data && elements[i] == elements[i + 1]) return true;
}
return false;
}
template<class T>
void Stack<T>::reverse()
{
T* temp = new T[_capacity];
size_t tail = _top;
for (size_t i = 0; i < tail; ++i) {
cout<<i<<" "<<peek()<<endl;
temp[i] = pop();
cout<<i<<" temp "<<temp[i]<<endl;
}
delete[] elements;
elements = temp;
_top = tail;
cout<<" elements "<<elements[0]<<endl;
}

Step by stepSolved in 2 steps with 1 images

- C++ Hello im trying to make a list for my code but i cant use the <list> library, how would i make a list for my linked list array based hashtable code wordlist: incase you want to test the entire code a aaa hello goodbye #pragma once //hashtable.h #include <iostream> #include <string> #include <list> #include <cstdlib> #include "word.h" using namespace std; class HashTable { int BUCKET; list<Word>* table; public: HashTable(int W); //to check if the table is empty bool isEmpty() const; //to insert a key into the hashtable void insertItem(string& x); //to delete a key from the hashtable void deleteItem(int key); int hashFunction(Word x); //to look for the key in the table bool searchTable(string& key); void displayHash(); }; //hashtable.cpp #include "hashtable.h" #include <iostream> HashTable::HashTable(int W) { table = new list < Word >[W]; BUCKET = W; return; } //to check if the table is empty bool…arrow_forwardstacks and queues. program must be able to handle all test cases without causing an exception Note that this problem does not require recursion to solve (though you can use that if you wish).arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





