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

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

问题描述

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

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天全站免登陆