@ashuthosh:
    MAintaining min and max pointers would mean another way of saying
constant space right?

On Thu, Sep 30, 2010 at 12:17 AM, saurabh singh <saurabh.n...@gmail.com>wrote:

> You will just need to see what is min and max available on the current top
> before push. in case of pop u dnt need to do anything...
>
> consider this array imp of stack
> each array index is stored with this object : {data, min_till_here,
> max_till_here}
>
> ------------------------------------------------------------->Top
> [{4,4,4} , {2,2,4}, {7,2,7} , {-6,-6,7}, {1,-6,7}, {9,-6,9}]
>
>
>
> So if u push say 20 then at top u see whats max and min till now. since
> curr min (-6) is smaller than 20 so min remains unaffected and since curr
> max (9) is smaller than 20 so curr max becomes 20. Hence the object at top
> in stack looks like {20,-6,20}
>
>
> On Wed, Sep 29, 2010 at 10:18 PM, albert theboss 
> <alberttheb...@gmail.com>wrote:
>
>>
>> when we pop out something ....
>> we need to find the max min again if max or min is popped out...
>> this ll take again O(n) to find max and min....
>>
>> Correct me if am wrong....
>>
>>  --
>> 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.
>>
>
>
>
> --
> Thanks & Regards,
> Saurabh
>
>  --
> 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.
>



-- 
------------------------------------------------------------
I dare do all that may become a man; Who dares do more, is none - Macbeth,
twelfh night!
Regards
       Krishna

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