小编Zer*_*KEz的帖子

理解python中的堆栈和队列

所以我得到了这个问题.考虑具有标准操作集的Stack和Queue类.使用Stack和Queue类,在调用mysteryFunction之前调用mysteryFunction之前包含哪些项目?

这是代码:

def mysteryFunction(s, q):
    q.enqueue('csc148')
    q.enqueue(True)
    q.enqueue(q.front())
    q.enqueue('abstract data type')

    for i in range(q.size()):
        s.push(q.dequeue())

    while not s.is_empty():
        q.enqueue(s.pop())


if __name__ == '__main__':
    s=Stack()
    q=Queue()

#About to call mysteryFunction
#What are contents of s and q at this point?
    mysteryFunction(s, q)
#mysteryFunction has been called.
#What are contents of s and q at this point?
Run Code Online (Sandbox Code Playgroud)

我无法理解面向对象编程,因为我是这个主题的新手.是否有任何链接可以分解堆栈和队列以及它们的作用?

python python-3.x

12
推荐指数
2
解决办法
1万
查看次数

标签 统计

python ×1

python-3.x ×1