“常用公式”在线计算,“设计手册”在线查询
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 支持支持 反对反对

共 1 个关于本帖的回复 最后回复于 2013-7-30 17:07

沙发
邢城 新来的 发表于 2013-7-30 17:07:27 | 只看该作者
研发埠培训中心
Describe a stack data structure that supports "push","pop",and " findminimum"operations."Findminimum" returns the smallest element in the stack.Good Answer:Store two stacks,one of which contains all of the items in the stackand one of which is a stack of minima.To push an element,push it on to the firststack.Check whether it is smaller than the top item on these condstack;if so,pushit onto these condstack.To pop an item,pop it from the firs tstack.If it is the top element of these condstack,pop it from these condstack.To find the minimumelement,simply return the element on the top of these condstack.Each operationtakes O(1) time.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注我们

360网站安全检测平台