Professional Documents
Culture Documents
top = -1;
}
bool IsFull() {
return top == (Size - 1);
}
bool IsEmpty() {
return top == -1;
}
int Pop() {
if (!IsEmpty()) {
cout <<" Removed Ellement from Stack is: ";
return stack[top];
}
else {
cout << "Stack is Empty,Pop operation can't be done";
}
}
void Print() {
for (int i = top; i >=0 ; i--)
{
cout << i << " Ellement: " << stack[i] << endl;
}
}
int Empty_Stack_Cells()
{
return (Size - top) - 1;
}
int Full_Stack_Cells() {
return top + 1;
}
};
class Stack_node
{
public:
int data;
Stack_node* next;
};
class linked_list_Stack
{
Stack_node *top;
public:
linked_list_Stack() {
top = NULL;
}
bool IsEmpty() {
return top == NULL;
}
void Push(int Value) {
Stack_node* newnode;
newnode = new Stack_node;
newnode->data = Value;
if (!IsEmpty()) {
newnode->next = top;
top = newnode;
}
else {
newnode->next = NULL;
}
cout << "Insertion is Done SuccesFully.\n";
}
void Pop() {
Stack_node* temp = top;
cout << "Removed Ellement from Stack is " << temp->data << endl;
top = temp->next;
delete temp;
}
void Print() {
Stack_node* temp = top;
while (temp->next != NULL) {
cout << temp->data << endl;
temp = temp->next;
}
cout << temp->data << endl;
}
};
void main() {