//CIS:610-251 Data Structures and Algos //Assignment # 2 Question # 1 //Stack Operations #include class Stack { private: int * data; //data value in stack unsigned sp; // Stack Pointer unsigned spMax; //Max Stack Pointer Value; public: Stack() ; Stack(Stack& s); Stack(unsigned size); void push(int); int pop() ; int StackTop(); bool Empty(void); }; //Constructor Stack::Stack() { data=new int(256); //init data as an array of 256 integer sp=0; //Stack initialized spMax=255; data[0]=NULL; } //Constructor if size of Stack is given Stack::Stack(unsigned size) { sp=0; spMax=size; data=new int(size+1); data[0]=NULL; } //Copy Constructor Stack::Stack(Stack& s) { unsigned i=1; this->sp=s.sp; this->spMax=s.spMax; this->data=new int[this->spMax+1]; for(;i<=sp;i++) this->data[i]=s.data[i]; } //Empty bool Stack::Empty(void) { if (sp) return false ; else return true; } //Add an element to Stack and increment the SP. void Stack::push(int item) { data[++sp]=item; } //Return the Top most element of stack and decrement the SP int Stack::pop() { return data[sp--]; } //return how many elements in Stack. int Stack::StackTop() { return data[sp]; } main() { Stack main; int i=0,n=3; main.push(2); main.push(9); main.push(7); main.push(3); main.push(50); main.push(44); main.push(13); //a if (!main.Empty()) main.pop(); if (!main.Empty()) i=main.pop(); cout << "Second Item from Top = " << i; //b Stack temp1(main); if (!temp1.Empty()) temp1.pop(); if (!temp1.Empty()) i=temp1.pop(); cout << "\nSecond Item from Top = " << i; //c for(i=1;i