Hi Jitendra,

For overflow condition, I think you also need to add.
when top2 == top1. that also creates overflow condition where we overrite
last element of other stack.
Anand
On Tue, Jun 1, 2010 at 9:08 AM, Jitendra Kushwaha
<jitendra.th...@gmail.com>wrote:

> Start the first stack from the starting of the array and the second array
> from the end as shown below
>
> -------->                                                      <--------
>
> --------------------------------------------------------------------------
> 0                                                                       n
>
> now for underflow condition  will be
> stack 1  if (top1 == 0)
> stack 2  if (top2 == n)
>
> and overflow condition will be
> if (top2-top1+1 == 0)
>
> thats it....
> correct me if anything wrong
>
>  On Tue, Jun 1, 2010 at 2:11 PM, Raj N <rajn...@gmail.com> wrote:
>
>> 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
>> "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<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Regards
> Jitendra Kushwaha
> Undergradute Student
> Computer Science & Eng.
> MNNIT, Allahabad
>
> --
> 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<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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.

Reply via email to