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

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

问题描述

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

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)

步骤 1 反向:)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

回答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

推荐答案

希望这将帮助您可视化 Stack 及其工作原理.

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

空栈:

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

Push A后,得到:

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

Push B后,得到:

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

弹出后,你得到:

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

Push C后,得到:

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

弹出后,你得到:

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

弹出后,你得到:

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

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

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