for three stacks u can use indices 0 3 6 etc for stack1. 1 4 7 for stack 2 and 2 5 8 etc for stack 3. now if any of the stack overflows but there is still space in array as other stacks have few element then now u can grow ur stack in reverse direction as shown below :
indices of array : 0 1 2 3 4 5 6 7 8 9 10 11 12 contents 1 2 3 1 1 1 1 / \ \ top2 top3 top1 here 1 represents element of stack1 2 for stack 2 and so on. now if u want to insert more element in stack 1 it will overflow while 2 and 3 have space so wat u can do now is grow stack 1 in reverse direction. ie now place elements for stack 1 in index 11 and so now top1 will point to 11 and so on. u can indicate this behaviour of stack1 by using some tag. i hope this will work.. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.