Stack implementation using linked list

We will be understanding the stack implementation using linked list. So, please understand the link list before proceeding. Lets understand how we can implement the different operation using linked list. CPP implementation Here is how we use linked list to implement stack in cpp: #include <iostream> using namespace std; struct node { int info; struct node \*next; }; struct node \*top; int empty() { return((top == NULL)? 1:0); } void push(int n) { struct node \*p; p=new node; if(p! [Read More]

Program to check if the stack grows up or down

#include 
#include 

void stack(int *local1);

int main()
{
  int local1;
  stack(&local1);
  exit(0);
}

void stack(int *local1)
{
   int local2;
   printf("\nAddress of first  local : [%u]", local1);
   printf("\nAddress of second local : [%u]", &local2);
   if(local1 < &local2)
   {
     printf("\nStack is growing downwards.\n”);
   }
   else
   {
     printf("\nStack is growing upwards.\n”);
   }
   printf("\n\n”);
}

Stack ADT

Stacks are an elementary Data Structure where all interaction with the data is done through the looking at the first element. Stacks are last in first out (LIFO) data structures. It is named on the basis of how the elements are removed from it. Opposite to stack is queue, in which the last element is removed, the element which was most old item, and hence it is FIFO or first in first out data structure. [Read More]