数组,链接列表和堆栈有什么区别? [英] What is the difference between Arrays, Linked-lists and Stacks?
问题描述
我目前正在学习算法和数据结构的基础知识,但对数组,链接列表和堆栈之间的概念以及区别感到有些困惑。
I'm currently learning the fundamentals of Algorithms and Data Structures and I am slightly confused about the concepts and the differences between arrays, linked-lists and stacks.
如果我错了,请纠正我:堆栈是否更像是一个抽象概念,而数组和链接列表是数据结构? (因此,我们可以使用数组或链接列表来实现堆栈的概念)
Please correct me if I am wrong: Is stack more like an abstract concept, and arrays and linked-lists are data structures? (Hence we can use either arrays or linked-lists to implement the concept of stack)
推荐答案
数组
一本书是一个数组。您可以按索引转到任何页面,并按自己喜欢的增量快速前进或后退。
A book is an array. You can go to any page by index and quickly go forwards or backwards by any increment you like.
链接列表
寻宝游戏是一个链表。您只能从一个项目转到下一个项目,因为每个项目都包含找到下一个项目的信息。
A scavenger hunt is a linked list. You can only go from one item to the next, because each item contains the information where to find the next item.
堆栈
书桌上的一堆字母是一堆。您只能看到顶部的字母。删除前一个字母会显示下一个字母。
A pile of letters on your desk is a stack. You can only see the letter lying on top. Removing the top letter reveals the next letter.
这篇关于数组,链接列表和堆栈有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!