堆栈是哪种类型的数据结构? [英] Which type of data structure is a stack?

查看:56
本文介绍了堆栈是哪种类型的数据结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题:堆栈是哪种数据结构?它是静态还是动态数据结构?我一直在寻找答案,找不到答案,因此我得到了自己的解释"-我猜想,当您可以通过使用数组或链接列表来实现它时,它可以是...两者?在执行上?我的推理有意义吗?

I got one simple question: which kind of data structure is a stack? Is it a static or dynamic data structure? I was looking for the answer and couldn't find it, therefore I got my own "explanation" - I guess, when you can implement it either by using an array or a linked list, it can be... both?, depending on implementation? Does my reasoning make any sense?

推荐答案

根据定义,静态数据结构的大小固定.如果您可以将堆栈的大小限制为某个预定数量,则堆栈将成为静态数据结构.它的大小是其存储大小,再加上指示当前位置的堆栈指针或堆栈索引的大小.

By definition, a static data structure has fixed size. If you can limit the size of your stack to some pre-determined number, your stack becomes a static data structure. Its size is the size of its storage, plus the size of the stack pointer or stack index indicating the current location.

无限制容量的堆栈是动态数据结构,无论其实现如何.它可以用链表或在达到其容量后重新分配的数组来实现,但是此类堆栈的大小随添加或删除数据而变化.

A stack of an unlimited capacity is a dynamic data structure, regardless of its implementation. It could be implemented with a linked list or an array that you re-allocate upon reaching its capacity, but the size of such stack changes as you add or remove data.

这篇关于堆栈是哪种类型的数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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