Enter your email address:


C Books Guide and List
C++ Books Guide and List
Best Java Books

algorithm Checking if the stack is empty

0 votes
algorithm Checking if the stack is empty
asked by aryan Jr Member (840 points)

1 Answer

0 votes

Checking if a stack is empty

Array implementation
    

int isEmpty(stack *stk){
    if(stk -> top == -1)
        return 1; //stack is empty
    else
        return 0; //stack is not empty
}

Linked list implementation

    
int isEmpty(stack *stk){
    if(stk -> top == NULL)
        return 1; //stack is empty
    else return 0;    //stack is not empty
}

answered by Smita Advisor (7,120 points)

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer