This commit is contained in:
krahets
2023-02-26 19:53:32 +08:00
parent 62d7f2c85d
commit d5d3a29676
31 changed files with 179 additions and 1 deletions
@@ -1581,6 +1581,8 @@
<li><strong>非线性数据结构</strong>:树、图、堆、哈希表;</li>
</ul>
<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. &nbsp; 物理结构:连续与离散<a class="headerlink" href="#322" title="Permanent link">&para;</a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
@@ -1588,6 +1590,8 @@
</div>
<p><strong>「物理结构」反映了数据在计算机内存中的存储方式</strong>。从本质上看,分别是 <strong>数组的连续空间存储</strong><strong>链表的离散空间存储</strong>。物理结构从底层上决定了数据的访问、更新、增删等操作方法,在时间效率和空间效率方面呈现出此消彼长的特性。</p>
<p><img alt="连续空间存储与离散空间存储" src="../classification_of_data_structure.assets/classification_phisical_structure.png" /></p>
<p align="center"> Fig. 连续空间存储与离散空间存储 </p>
<p><strong>所有数据结构都是基于数组、或链表、或两者组合实现的</strong>。例如栈和队列,既可以使用数组实现、也可以使用链表实现,而例如哈希表,其实现同时包含了数组和链表。</p>
<ul>
<li><strong>基于数组可实现</strong>:栈、队列、哈希表、树、堆、图、矩阵、张量(维度 <span class="arithmatex">\(\geq 3\)</span> 的数组)等;</li>
@@ -1747,6 +1747,8 @@
\end{aligned}
\]</div>
<p><img alt="IEEE 754 标准下的 float 表示方式" src="../data_and_memory.assets/ieee_754_float.png" /></p>
<p align="center"> Fig. IEEE 754 标准下的 float 表示方式 </p>
<p>以上图为例,<span class="arithmatex">\(\mathrm{S} = 0\)</span> <span class="arithmatex">\(\mathrm{E} = 124\)</span> <span class="arithmatex">\(\mathrm{N} = 2^{-2} + 2^{-3} = 0.375\)</span> ,易得</p>
<div class="arithmatex">\[
\text { val } = (-1)^0 \times 2^{124 - 127} \times (1 + 0.375) = 0.171875
@@ -1871,6 +1873,8 @@
<p><strong>算法运行中,相关数据都被存储在内存中</strong>。下图展示了一个计算机内存条,其中每个黑色方块都包含一块内存空间。我们可以将内存想象成一个巨大的 Excel 表格,其中每个单元格都可以存储 1 byte 的数据,在算法运行时,所有数据都被存储在这些单元格中。</p>
<p><strong>系统通过「内存地址 Memory Location」来访问目标内存位置的数据</strong>。计算机根据特定规则给表格中每个单元格编号,保证每块内存空间都有独立的内存地址。自此,程序便通过这些地址,访问内存中的数据。</p>
<p><img alt="内存条、内存空间、内存地址" src="../data_and_memory.assets/computer_memory_location.png" /></p>
<p align="center"> Fig. 内存条、内存空间、内存地址 </p>
<p><strong>内存资源是设计数据结构与算法的重要考虑因素</strong>。内存是所有程序的公共资源,当内存被某程序占用时,不能被其它程序同时使用。我们需要根据剩余内存资源的情况来设计算法。例如,若剩余内存空间有限,则要求算法占用的峰值内存不能超过系统剩余内存;若运行的程序很多、缺少大块连续的内存空间,则要求选取的数据结构必须能够存储在离散的内存空间内。</p>