跳转至

3.2. 什么是线性结构?

3.2. What Are Linear Structures?

我们将从研究四个简单但非常强大的概念开始:栈、队列、双端队列和列表。这些是数据集合的示例,其项的顺序取决于它们的添加或移除方式。一旦一个项被添加,它将保持相对于其他之前和之后的元素的位置。这些集合通常被称为线性数据结构

线性结构可以被看作有两个端点。有时这些端点被称为,或者在某些情况下是。你也可以称它们为“顶部”和底部。这些名称的给予并不重要。区别一个线性结构与另一个结构的是项的添加和移除方式,特别是这些添加和移除发生的位置。例如,一个结构可能只允许在一个端点添加新项。有些结构可能允许从任意一个端点移除项。

这些变化产生了计算机科学中最有用的数据结构之一。它们出现在许多算法中,并可以用来解决各种重要的问题。

We will begin our study of data structures by considering four simple but very powerful concepts. Stacks, queues, deques, and lists are examples of data collections whose items are ordered depending on how they are added or removed. Once an item is added, it stays in that position relative to the other elements that came before and came after it. Collections such as these are often referred to as linear data structures.

Linear structures can be thought of as having two ends. Sometimes these ends are referred to as the left and the right, or in some cases the front and the rear. You could also call them the “top” and the bottom. The names given to the ends are not significant. What distinguishes one linear structure from another is the way in which items are added and removed, in particular the location where these additions and removals occur. For example, a structure might allow new items to be added at only one end. Some structures might allow items to be removed from either end.

These variations give rise to some of the most useful data structures in computer science. They appear in many algorithms and can be used to solve a variety of important problems.


最后更新: 2024年9月12日
创建日期: 2024年9月9日