mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-28 04:42:48 +08:00
deploy
This commit is contained in:
@ -15,17 +15,17 @@
|
||||
<link rel="canonical" href="https://www.hello-algo.com/chapter_data_structure/classification_of_data_structure/">
|
||||
|
||||
|
||||
<link rel="prev" href="../data_and_memory/">
|
||||
<link rel="prev" href="../../chapter_computational_complexity/summary/">
|
||||
|
||||
|
||||
<link rel="next" href="../summary/">
|
||||
<link rel="next" href="../basic_data_types/">
|
||||
|
||||
<link rel="icon" href="../../assets/images/favicon.png">
|
||||
<meta name="generator" content="mkdocs-1.4.2, mkdocs-material-9.1.6">
|
||||
|
||||
|
||||
|
||||
<title>3.2. 数据结构分类 - Hello 算法</title>
|
||||
<title>3.1. 数据结构分类 - Hello 算法</title>
|
||||
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
<div data-md-component="skip">
|
||||
|
||||
|
||||
<a href="#32" class="md-skip">
|
||||
<a href="#31" class="md-skip">
|
||||
跳转至
|
||||
</a>
|
||||
|
||||
@ -113,7 +113,7 @@
|
||||
<div class="md-header__topic" data-md-component="header-topic">
|
||||
<span class="md-ellipsis">
|
||||
|
||||
3.2. 数据结构分类
|
||||
3.1. 数据结构分类
|
||||
|
||||
</span>
|
||||
</div>
|
||||
@ -544,17 +544,21 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<label class="md-nav__link" for="__nav_4" id="__nav_4_label" tabindex="0">
|
||||
3. 数据结构简介
|
||||
3. 数据结构与数据
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
</label>
|
||||
|
||||
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="true">
|
||||
<label class="md-nav__title" for="__nav_4">
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
3. 数据结构简介
|
||||
3. 数据结构与数据
|
||||
</label>
|
||||
<ul class="md-nav__list" data-md-scrollfix>
|
||||
|
||||
@ -562,20 +566,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="../data_and_memory/" class="md-nav__link">
|
||||
3.1. 基本数据类型
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -588,12 +578,12 @@
|
||||
|
||||
|
||||
<label class="md-nav__link md-nav__link--active" for="__toc">
|
||||
3.2. 数据结构分类
|
||||
3.1. 数据结构分类
|
||||
<span class="md-nav__icon md-icon"></span>
|
||||
</label>
|
||||
|
||||
<a href="./" class="md-nav__link md-nav__link--active">
|
||||
3.2. 数据结构分类
|
||||
3.1. 数据结构分类
|
||||
</a>
|
||||
|
||||
|
||||
@ -612,15 +602,15 @@
|
||||
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#321" class="md-nav__link">
|
||||
3.2.1. 逻辑结构:线性与非线性
|
||||
<a href="#311" class="md-nav__link">
|
||||
3.1.1. 逻辑结构:线性与非线性
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#322" class="md-nav__link">
|
||||
3.2.2. 物理结构:连续与离散
|
||||
<a href="#312" class="md-nav__link">
|
||||
3.1.2. 物理结构:连续与离散
|
||||
</a>
|
||||
|
||||
</li>
|
||||
@ -639,9 +629,51 @@
|
||||
|
||||
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="../basic_data_types/" class="md-nav__link">
|
||||
3.2. 基本数据类型
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="../number_encoding/" class="md-nav__link">
|
||||
3.3. 数字编码 *
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="../character_encoding/" class="md-nav__link">
|
||||
3.4. 字符编码 *
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="../summary/" class="md-nav__link">
|
||||
3.3. 小结
|
||||
3.5. 小结
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@ -1829,15 +1861,15 @@
|
||||
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#321" class="md-nav__link">
|
||||
3.2.1. 逻辑结构:线性与非线性
|
||||
<a href="#311" class="md-nav__link">
|
||||
3.1.1. 逻辑结构:线性与非线性
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#322" class="md-nav__link">
|
||||
3.2.2. 物理结构:连续与离散
|
||||
<a href="#312" class="md-nav__link">
|
||||
3.1.2. 物理结构:连续与离散
|
||||
</a>
|
||||
|
||||
</li>
|
||||
@ -1865,9 +1897,9 @@
|
||||
|
||||
|
||||
|
||||
<h1 id="32">3.2. 数据结构分类<a class="headerlink" href="#32" title="Permanent link">¶</a></h1>
|
||||
<h1 id="31">3.1. 数据结构分类<a class="headerlink" href="#31" title="Permanent link">¶</a></h1>
|
||||
<p>数据结构可以从逻辑结构和物理结构两个维度进行分类。</p>
|
||||
<h2 id="321">3.2.1. 逻辑结构:线性与非线性<a class="headerlink" href="#321" title="Permanent link">¶</a></h2>
|
||||
<h2 id="311">3.1.1. 逻辑结构:线性与非线性<a class="headerlink" href="#311" title="Permanent link">¶</a></h2>
|
||||
<p><strong>「逻辑结构」揭示了数据元素之间的逻辑关系</strong>。在数组和链表中,数据按照顺序依次排列,体现了数据之间的线性关系;而在树中,数据从顶部向下按层次排列,表现出祖先与后代之间的派生关系;图则由节点和边构成,反映了复杂的网络关系。</p>
|
||||
<p>逻辑结构通常分为「线性」和「非线性」两类。线性结构比较直观,指数据在逻辑关系上呈线性排列;非线性结构则相反,呈非线性排列,例如网状或树状结构。</p>
|
||||
<ul>
|
||||
@ -1877,12 +1909,15 @@
|
||||
<p><img alt="线性与非线性数据结构" src="../classification_of_data_structure.assets/classification_logic_structure.png" /></p>
|
||||
<p align="center"> Fig. 线性与非线性数据结构 </p>
|
||||
|
||||
<h2 id="322">3.2.2. 物理结构:连续与离散<a class="headerlink" href="#322" title="Permanent link">¶</a></h2>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>如若阅读起来有困难,建议先阅读下一章“数组与链表”,然后再回头理解物理结构的含义。</p>
|
||||
</div>
|
||||
<p><strong>「物理结构」体现了数据在计算机内存中的存储方式</strong>,可以分为数组的连续空间存储和链表的离散空间存储。物理结构从底层决定了数据的访问、更新、增删等操作方法,同时在时间效率和空间效率方面呈现出互补的特点。</p>
|
||||
<h2 id="312">3.1.2. 物理结构:连续与离散<a class="headerlink" href="#312" title="Permanent link">¶</a></h2>
|
||||
<p>在计算机中,内存和硬盘是两种主要的存储硬件设备。「硬盘」主要用于长期存储数据,容量较大(通常可达到 TB 级别)、速度较慢。「内存」用于运行程序时暂存数据,速度较快,但容量较小(通常为 GB 级别)。</p>
|
||||
<p><strong>在算法运行过程中,相关数据都存储在内存中</strong>。下图展示了一个计算机内存条,其中每个黑色方块都包含一块内存空间。我们可以将内存想象成一个巨大的 Excel 表格,其中每个单元格都可以存储 1 byte 的数据,在算法运行时,所有数据都被存储在这些单元格中。</p>
|
||||
<p><strong>系统通过「内存地址 Memory Location」来访问目标内存位置的数据</strong>。计算机根据特定规则为表格中的每个单元格分配编号,确保每个内存空间都有唯一的内存地址。有了这些地址,程序便可以访问内存中的数据。</p>
|
||||
<p><img alt="内存条、内存空间、内存地址" src="../classification_of_data_structure.assets/computer_memory_location.png" /></p>
|
||||
<p align="center"> Fig. 内存条、内存空间、内存地址 </p>
|
||||
|
||||
<p>内存是所有程序的共享资源,当内存被某个程序占用时,其他程序无法同时使用。<strong>因此,在数据结构与算法的设计中,内存资源是一个重要的考虑因素</strong>。例如,算法所占用的内存峰值不应超过系统剩余空闲内存;如果运行的程序很多并且缺少大量连续的内存空间,那么所选用的数据结构必须能够存储在离散的内存空间内。</p>
|
||||
<p><strong>「物理结构」反映了数据在计算机内存中的存储方式</strong>,可分为数组的连续空间存储和链表的离散空间存储。物理结构从底层决定了数据的访问、更新、增删等操作方法,同时在时间效率和空间效率方面呈现出互补的特点。</p>
|
||||
<p><img alt="连续空间存储与离散空间存储" src="../classification_of_data_structure.assets/classification_phisical_structure.png" /></p>
|
||||
<p align="center"> Fig. 连续空间存储与离散空间存储 </p>
|
||||
|
||||
@ -1894,7 +1929,7 @@
|
||||
<p>基于数组实现的数据结构也被称为「静态数据结构」,这意味着此类数据结构在初始化后长度不可变。相对应地,基于链表实现的数据结构被称为「动态数据结构」,这类数据结构在初始化后,仍可以在程序运行过程中对其长度进行调整。</p>
|
||||
<div class="admonition tip">
|
||||
<p class="admonition-title">Tip</p>
|
||||
<p>数组与链表是其他所有数据结构的“底层积木”,建议读者投入更多时间深入了解这两种基本数据结构。</p>
|
||||
<p>如若感觉理解物理结构有困难,建议先阅读下一章“数组与链表”,然后再回头理解物理结构的含义。数组与链表是其他所有数据结构的基石,建议你投入更多时间深入了解这两种基本数据结构。</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -1973,7 +2008,7 @@
|
||||
<nav class="md-footer__inner md-grid" aria-label="页脚" >
|
||||
|
||||
|
||||
<a href="../data_and_memory/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 3.1. &nbsp; 基本数据类型" rel="prev">
|
||||
<a href="../../chapter_computational_complexity/summary/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 2.4. &nbsp; 小结" rel="prev">
|
||||
<div class="md-footer__button md-icon">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
|
||||
</div>
|
||||
@ -1982,20 +2017,20 @@
|
||||
上一页
|
||||
</span>
|
||||
<div class="md-ellipsis">
|
||||
3.1. 基本数据类型
|
||||
2.4. 小结
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<a href="../summary/" class="md-footer__link md-footer__link--next" aria-label="下一页: 3.3. &nbsp; 小结" rel="next">
|
||||
<a href="../basic_data_types/" class="md-footer__link md-footer__link--next" aria-label="下一页: 3.2. &nbsp; 基本数据类型" rel="next">
|
||||
<div class="md-footer__title">
|
||||
<span class="md-footer__direction">
|
||||
下一页
|
||||
</span>
|
||||
<div class="md-ellipsis">
|
||||
3.3. 小结
|
||||
3.2. 基本数据类型
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-footer__button md-icon">
|
||||
|
Reference in New Issue
Block a user