In the stack example program add a method called searchchar
Solution
Hi Friend, YOu have not posted whole progtam of stack implementation, so I do not have clear unserstanding of all methods implementation.
But I have implemented:
 // search method implementation
void search(char c){
   
    // if stack is empty
    if(empty()){
        cout<<c<<\" not avaialble in stack\"<<endl;
        return;
    }
   // getting top element
    char t = pop(); // getting top element
    if(t == c){
        cout<<c<<\" is now found at top\"<<endl;
        push(t); // push again popped element in stack
        return;
    }
       
    search(c); // calling search recursively
   
    // now popped element back to stack
    push(t);
}
Time Complexity: Worst case scenario occurs when \'c\' is available at bottom of stack or \'c\' is not in stack
In this case we need to pop all elements and again we need to push in stack
So, if N is the total number of elements in stack then It takes : O(2*N) = O(N)

