Multiple stacks :
Print this page
 

ALGORITHM TO BE APPLIED WHEN T [i] = = B [i] CONDITION IS ENCOUNTERED WHILE DOING PUSH OPERATION.

   
 
STACK_FULL  
{

1. Find j such that i < j <= n and there is a free space between stack j    and stack (j +1).
if such a j exist , then move stack i+1 , i+2 ,.........till j one position to the right and hence create space for element between stack i and i +1.       

 
2. Else
Find j such that 1 <= j < i and there is a free space between stack j and stacK(j +1).
if such a j exist , then move stack j+1 , j+2 ,.......till i one position to the left and hence  create space for element between stack i and i +1 .
3. Else  
If none of above is possible then there is no space left out in the one-dimensional array used hence print no space for push operation.
 
}
Prev