Push 和 Pop 对 Stacks 意味着什么? [英] What do Push and Pop mean for Stacks?

查看:50
本文介绍了Push 和 Pop 对 Stacks 意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

长话短说,我的讲师是废话,他通过高架投影仪向我们展示了前缀堆栈的中缀,他的大影子挡住了一切,所以我错过了重要的东西

long story short my lecturer is crap, and was showing us infix to prefix stacks via an overhead projector and his bigass shadow was blocking everything so i missed the important stuff

他指的是push和pop,push = 0 pop = x

he was referring to push and pop, push = 0 pop = x

他举了个例子,但我完全看不出他是怎么得到答案的,

he gave an example but i cant see how he gets his answer at all,

2*3/(2-1)+5*(4-1)

step 1 Reverse : )1-4(*5+)1-2(/3*2 好的,我可以看到

step 1 Reverse : )1-4(*5+)1-2(/3*2 ok i can see that

然后他继续写 x 和 o 的操作,我完全迷路了

he then went on writing x's and o's operations and i got totally lost

answer 14-5*12-32*/+ 然后再次反转得到 +/*23-21*5-41

answer 14-5*12-32*/+ then reversed again to get +/*23-21*5-41

如果有人能向我解释一下push pop,这样我就可以理解了,我会非常高兴,我已经在网上看了,但我发现的很多东西似乎都比这更重要,所以我真的需要先在这里了解一下

if some one could explain to me the push pop so i could understand i would be very greatful, i have looked online but alot stuff im finding seems to be a step above this, so i really need to get an understanding here first

推荐答案

希望这能帮助您可视化堆栈及其工作原理.

Hopefully this will help you visualize a Stack, and how it works.

空栈:

|     |
|     |
|     |
-------

按下A后,你得到:

|     |
|     |
|  A  |
-------

按下B后,你得到:

|     |
|  B  |
|  A  |
-------

弹出后,您将获得:

|     |
|     |
|  A  |
-------

推送C后,你得到:

|     |
|  C  |
|  A  |
-------

弹出后,您将获得:

|     |
|     |
|  A  |
-------

弹出后,您将获得:

|     |
|     |
|     |
-------

这篇关于Push 和 Pop 对 Stacks 意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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