栈的pop和peek_从堆栈中移除项目,而不使用pop、peek、push

我不明白他们在问什么。有人能澄清这个问题吗?在

问题是:(他们给了我们doc字符串)

在stack_数组模块中编写并测试方法combine。从名为q3.py的模块测试它。在

这是在扩展Stack类。它应该产生与问题1相同的结果,但它必须在堆栈代码定义的最低级别工作。换句话说,这个方法不能调用堆栈push-and-pop,它必须直接处理值。在def combine(self, s2):

"""

-------------------------------------------------------

Combines a second stack with the current stack.

(iterative algorithm)

Use: s3 = s1.combine(s2)

-------------------------------------------------------

Preconditions:

s2 - an array-based stack (Stack)

Postconditions:

Returns:

s3 - the contents of the current stack and s2

are interlaced into s3 - current stack and s2

are empty (Stack)

-------------------------------------------------------

"""

#Write your code here

我已经解决了推,弹出,偷看。在

^{pr2}$

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值