Multiple choice

Fill in the blank. Where 'i' is the stack no. and 'x' is the item to be inserted. void Push( int i, int x ) {
if(-------) printf(Stackoverflow); elseS[++Top]=x;
}

  1. Top[i]=Top[i+1]

  2. Top[i]=Bottom[i+1]

  3. Top[i]=Bottom[i]

  4. Top[i]=Bottom[i-1]

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Here 'i' is the stack number, if stack i is full then bottom of new stack begins from there, applicable for multilevel queue. For multilevel queue (n/m)*i - 1, where n is the size of array, m is the size of stack and i is the stack number, let n =9, m=3, then three stacks can be implemented on it. So i = 0, 1, 2. Put i in formula (n/m)*i - 1 for 0 we get -1, -1 is bottom of first stack. Put i=1, we get 2, and 2 is the top for first stack and bottom for second stack. Option says top of first queue is equal to bottom of second queue. So, it is the correct option. As first stack is full, this satisfies the overflow condition.