Re: [algogeeks] Implementing 2 stacks within a single linear array

2010-06-03 Thread divya jain
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

Re: [algogeeks] Implementing 2 stacks within a single linear array

2010-06-03 Thread manchit gupta
three or more stacks can be made by using linked array representation -- 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

Re: [algogeeks] Implementing 2 stacks within a single linear array

2010-06-03 Thread Jitendra Kushwaha
@Raj N : You are right overflow is top2-(top1+1)==0 @Anand : The oveflow condition is dependent how underflow condition are implemented. Considering underflow above condition for overflow suffice For 3 stacks a efficient algo is not easy to think in a single array , yet we can optimise

Re: [algogeeks] Implementing 2 stacks within a single linear array

2010-06-02 Thread Raj N
@Jitendra: Hey that condition for overflow is it not top2-(top1+1)==0 And how to implement 3 stacks using the same On Tue, Jun 1, 2010 at 9:38 PM, Jitendra Kushwaha jitendra.th...@gmail.comwrote: Start the first stack from the starting of the array and the second array from the end as shown

[algogeeks] Implementing 2 stacks within a single linear array

2010-06-01 Thread Raj N
Hi all, Can someone suggest me an efficient way to implement 2 stacks within a single linear array assuming neither of the stack overflows and an entire stack is never shifted to a different location within the array. -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Implementing 2 stacks within a single linear array

2010-06-01 Thread Sudarshan Reddy M
Hi, the stacks can implemented in the array one is starting at the begin and other is starting at the end growing in opposite directions. If the stack tops are colloid then there is no space left; means no room for extra elemnts. Thanks Sudarshan. On Tue, Jun 1, 2010 at 2:11 PM, Raj N

Re: [algogeeks] Implementing 2 stacks within a single linear array

2010-06-01 Thread Jitendra Kushwaha
Start the first stack from the starting of the array and the second array from the end as shown below -- 0

Re: [algogeeks] Implementing 2 stacks within a single linear array

2010-06-01 Thread Raj N
How to implement 3 stacks using the same? On Tue, Jun 1, 2010 at 8:59 PM, Sudarshan Reddy M sudarsha...@gmail.comwrote: Hi, the stacks can implemented in the array one is starting at the begin and other is starting at the end growing in opposite directions. If the stack tops are colloid then