You can do this using two stacks
---------------------------------------------------------------------------------------------------------------------------
Stack s, m;
Push(x):
s.push(x)
if(x > m.top())
if(x > m.top())
m.push(m.top())
else
m.push(x)
Pop():
m.pop()
return s.pop()
FindMin():
return m.top()
---------------------------------------------------------------------------------------------------------------------------
On 3/28/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Fine, I read it "can" be! Bone head!
Obvi can't, as some one already put it
that would mean sorting in O(n).
, 133470973390.236450, 270};
int main(){m[2]--?m[0]*=4,m[1]*=5,main():printf(m);}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---
- [algogeeks] DataStructure - Push,Pop & Find_Mi... Prunthaban Kanthakumar
- [algogeeks] Re: DataStructure - Push,Pop &... ridvansg
- [algogeeks] Re: DataStructure - Push,Pop ... Balaji Gopalan
- [algogeeks] Re: DataStructure - Push,... Vijay Venkat Raghavan N
- [algogeeks] Re: DataStructure - P... Mohammad Moghimi
- [algogeeks] Re: DataStructur... Prunthaban Kanthakumar
- [algogeeks] Re: DataStru... [EMAIL PROTECTED]
- [algogeeks] Re: Data... [EMAIL PROTECTED]
- [algogeeks] Re: Data... Mohammad Moghimi
- [algogeeks] Re: DataStructure - Push,Pop &... [EMAIL PROTECTED]
