static void insert_at_bottom(char x){
if(st.isEmpty())
st.push(x);
else{
/* All items are held in Function Call Stack until we
reach end of the stack. When the stack becomes
empty, the st.size() becomes 0, the
above if part is executed and the item is inserted
at the bottom */
char a = st.peek();
st.pop();
insert_at_bottom(x);
//push all the items held in Function Call Stack
//once the item is inserted at the bottom
st.push(a);
}
}
In the above code, I have a question about this step:
if(st.isEmpty())
st.push(x);
Don't we require a return statement after st.push(x)?
I mean that in recursion stack when that condition is satisfied i.e. when the stack is empty, it would push x into the stack, but how would it return to the previous call without the return statement?