且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

数组,链接列表和堆栈有什么区别?

更新时间:2023-11-09 13:01:46

数组

一本书是一个数组。您可以按索引转到任何页面,并按自己喜欢的增量快速前进或后退。

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.