数据结构与Java中的算法 [英] data structures & algorithms in java

查看:80
本文介绍了数据结构与Java中的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下字符堆栈,其中该堆栈分配了8个存储单元. Stack:a,9,e ,,,, __,在下面给出的每个操作的末尾给出堆栈的内容:i).pop()ii).pop()iii).push(e)iv ).push(1)v).pop()vi).push(i)vii).push(0)viii).pop()ix).push(o)x).push(u)

Consider the following stack of characters,where stack is allocated 8 memory cells. Stack:a,9,e,,,,,_, Give the contents of the stack at the end of the each operation given below: i).pop() ii).pop() iii).push(e) iv).push(1) v).pop() vi).push(i) vii).push(0) viii).pop() ix).push(o) x).push(u)

推荐答案

如果您要张贴作业,至少要使其看起来像您自己尝试做某事!

我们不做您的作业:这是有原因的.在这里,您可以考虑自己被告知的内容,并尝试理解它.也可以在那里帮助您的导师识别您的弱点,并将更多的注意力放在补救措施上.

自己尝试,或学习魔语:您想要炸薯条吗?"
If you are going to post your homework, at least try to make it look like you have attempted to do something yourself!

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, or learn the Magic Words: "Do you want fries with that?"


Stack代表LIFO(后进先出).
因此,假设a,9,e ,,,,, _,a在底部.
i).pop()//删除_
a,9,e ,, _ ,, _,
ii).pop()//删除_
a,9,e ,, _ ,,
iii).push(e)//添加e
a,9,e ,, _ ,, e,
iv).push(1)加1
a,9,e ,, _ ,, e,1,
v).pop()
a,9,e ,, _ ,, e,
vi).push(i)
a,9,e ,, _ ,, e,i,
vii).push(0)
a,9,e ,, _ ,, e,i,(不作为堆栈溢出推送)
viii).pop()
a,9,e ,, _ ,, e,
ix).push(o)
a,9,e ,, _ ,, e,o,
x).push(u)
a,9,e ,, _ ,, e,i,(不作为堆栈溢出推送)
Stack stands for LIFO (Last in First Out).
So assuming a,9,e,,,,,_, a is at the bottom.
i).pop() //removes _
a,9,e,,_,,_,
ii).pop() //removes _
a,9,e,,_,,
iii).push(e) //adds e
a,9,e,,_,,e,
iv).push(1) adds 1
a,9,e,,_,,e,1,
v).pop()
a,9,e,,_,,e,
vi).push(i)
a,9,e,,_,,e,i,
vii).push(0)
a,9,e,,_,,e,i, (Not pushed as stack overflow)
viii).pop()
a,9,e,,_,,e,
ix).push(o)
a,9,e,,_,,e,o,
x).push(u)
a,9,e,,_,,e,i, (Not pushed as stack overflow)


这篇关于数据结构与Java中的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆