Reverse stack without using any data structure

algorithm, stack

Solution

This can be done with double recursion , as follows: .

void insert_at_bottom(node **stack, int data)
{
     if( isempty(*stack) ){
          push(stack,data);
          return;
     }
     int temp=pop(stack);
     insert_at_bottom(stack,data);
     push(stack,temp);
}  


void rev_stack(node **stack)
{
     if( isempty(*stack) ) return;
     int temp = pop(stack);
     rev_stack(stack);
     insert_at_bottom(stack,temp);
}

Problem

How can I Reverse stack without using any (extra) data structure ? Any suggestions or Pseudo code could be helpful . I trying and couldn't find any viable solution . Problem here is I don-no the size of stack also . If i know that I could at-least proceed on creating something , Thanks in advance .

Original source