I have written a function for reverse a stack inline. these two are member function of stack class .
void reverse()
{
int first=pop();
if(first!=-1)
{
reverse();
insert(first);
}
}
private:
void insert(int i)
{
int temp=pop();
if(temp==-1)
{
push(i);
}
else
{
/* there is already a element in the stack*/
insert(i);
push(temp);
}
}
Now how can i analyze my function in form of big O to calculate complexity.