3,629 views
1 votes
1 votes
In a stack,(size of 1 to n) the command to access ith element from top of the stack S will be known as peep(S,i).what is the condition to check for underflow on peep??

A.S[top-i]<=0

B.S[top+i]<=0

C.S[top-i+1]<=0

D.none

1 Answer

1 votes
1 votes
At $Top : 1st$ element.

At $Top-1: 2nd$ element.

At $Top-2: 3rd$ element.

...

At $Top-(i-1): ith$ element.  Therefore $ith$ element is existing at $S[Top-i+1]$ which is if $\leq{0}$ implies the value is not existing. therefore C.

Related questions

0 votes
0 votes
1 answer
1
Abhrajyoti00 asked Oct 29, 2022
741 views
Can there be “Stack Overflow” in Linked list Implementation of stack? If Yes, how?