deploy
This commit is contained in:
parent
497ca41afd
commit
7f621508a6
Binary file not shown.
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
@ -4392,7 +4392,7 @@
|
||||
<tr>
|
||||
<td>存储方式</td>
|
||||
<td>连续内存空间</td>
|
||||
<td>离散内存空间</td>
|
||||
<td>分散内存空间</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>缓存局部性</td>
|
||||
|
@ -3312,7 +3312,7 @@
|
||||
<h1 id="44">4.4 小结<a class="headerlink" href="#44" title="Permanent link">¶</a></h1>
|
||||
<h3 id="1">1. 重点回顾<a class="headerlink" href="#1" title="Permanent link">¶</a></h3>
|
||||
<ul>
|
||||
<li>数组和链表是两种基本的数据结构,分别代表数据在计算机内存中的两种存储方式:连续空间存储和离散空间存储。两者的特点呈现出互补的特性。</li>
|
||||
<li>数组和链表是两种基本的数据结构,分别代表数据在计算机内存中的两种存储方式:连续空间存储和分散空间存储。两者的特点呈现出互补的特性。</li>
|
||||
<li>数组支持随机访问、占用内存较少;但插入和删除元素效率低,且初始化后长度不可变。</li>
|
||||
<li>链表通过更改引用(指针)实现高效的节点插入与删除,且可以灵活调整长度;但节点访问效率低、占用内存较多。常见的链表类型包括单向链表、循环链表、双向链表。</li>
|
||||
<li>动态数组,又称列表,是基于数组实现的一种数据结构。它保留了数组的优势,同时可以灵活调整长度。列表的出现极大地提高了数组的易用性,但可能导致部分内存空间浪费。</li>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 73 KiB |
@ -819,7 +819,7 @@
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#312" class="md-nav__link">
|
||||
3.1.2 物理结构:连续与离散
|
||||
3.1.2 物理结构:连续与分散
|
||||
</a>
|
||||
|
||||
</li>
|
||||
@ -3249,7 +3249,7 @@
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#312" class="md-nav__link">
|
||||
3.1.2 物理结构:连续与离散
|
||||
3.1.2 物理结构:连续与分散
|
||||
</a>
|
||||
|
||||
</li>
|
||||
@ -3327,17 +3327,17 @@
|
||||
<li><strong>树形结构</strong>:树、堆、哈希表,元素之间是一对多的关系。</li>
|
||||
<li><strong>网状结构</strong>:图,元素之间是多对多的关系。</li>
|
||||
</ul>
|
||||
<h2 id="312">3.1.2 物理结构:连续与离散<a class="headerlink" href="#312" title="Permanent link">¶</a></h2>
|
||||
<h2 id="312">3.1.2 物理结构:连续与分散<a class="headerlink" href="#312" title="Permanent link">¶</a></h2>
|
||||
<p>在计算机中,内存和硬盘是两种主要的存储硬件设备。硬盘主要用于长期存储数据,容量较大(通常可达到 TB 级别)、速度较慢。内存用于运行程序时暂存数据,速度较快,但容量较小(通常为 GB 级别)。</p>
|
||||
<p><strong>在算法运行过程中,相关数据都存储在内存中</strong>。图 3-2 展示了一个计算机内存条,其中每个黑色方块都包含一块内存空间。我们可以将内存想象成一个巨大的 Excel 表格,其中每个单元格都可以存储一定大小的数据,在算法运行时,所有数据都被存储在这些单元格中。</p>
|
||||
<p><strong>系统通过内存地址来访问目标位置的数据</strong>。如图 3-2 所示,计算机根据特定规则为表格中的每个单元格分配编号,确保每个内存空间都有唯一的内存地址。有了这些地址,程序便可以访问内存中的数据。</p>
|
||||
<p><a class="glightbox" href="../classification_of_data_structure.assets/computer_memory_location.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="内存条、内存空间、内存地址" src="../classification_of_data_structure.assets/computer_memory_location.png" /></a></p>
|
||||
<p align="center"> 图 3-2 内存条、内存空间、内存地址 </p>
|
||||
|
||||
<p>内存是所有程序的共享资源,当某块内存被某个程序占用时,则无法被其他程序同时使用了。<strong>因此在数据结构与算法的设计中,内存资源是一个重要的考虑因素</strong>。比如,算法所占用的内存峰值不应超过系统剩余空闲内存;如果缺少连续大块的内存空间,那么所选用的数据结构必须能够存储在离散的内存空间内。</p>
|
||||
<p>如图 3-3 所示,<strong>物理结构反映了数据在计算机内存中的存储方式</strong>,可分为连续空间存储(数组)和离散空间存储(链表)。物理结构从底层决定了数据的访问、更新、增删等操作方法,同时在时间效率和空间效率方面呈现出互补的特点。</p>
|
||||
<p><a class="glightbox" href="../classification_of_data_structure.assets/classification_phisical_structure.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="连续空间存储与离散空间存储" src="../classification_of_data_structure.assets/classification_phisical_structure.png" /></a></p>
|
||||
<p align="center"> 图 3-3 连续空间存储与离散空间存储 </p>
|
||||
<p>内存是所有程序的共享资源,当某块内存被某个程序占用时,则无法被其他程序同时使用了。<strong>因此在数据结构与算法的设计中,内存资源是一个重要的考虑因素</strong>。比如,算法所占用的内存峰值不应超过系统剩余空闲内存;如果缺少连续大块的内存空间,那么所选用的数据结构必须能够存储在分散的内存空间内。</p>
|
||||
<p>如图 3-3 所示,<strong>物理结构反映了数据在计算机内存中的存储方式</strong>,可分为连续空间存储(数组)和分散空间存储(链表)。物理结构从底层决定了数据的访问、更新、增删等操作方法,同时在时间效率和空间效率方面呈现出互补的特点。</p>
|
||||
<p><a class="glightbox" href="../classification_of_data_structure.assets/classification_phisical_structure.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="连续空间存储与分散空间存储" src="../classification_of_data_structure.assets/classification_phisical_structure.png" /></a></p>
|
||||
<p align="center"> 图 3-3 连续空间存储与分散空间存储 </p>
|
||||
|
||||
<p>值得说明的是,<strong>所有数据结构都是基于数组、链表或二者的组合实现的</strong>。例如,栈和队列既可以使用数组实现,也可以使用链表实现;而哈希表的实现可能同时包含数组和链表。</p>
|
||||
<ul>
|
||||
|
@ -3315,7 +3315,7 @@
|
||||
<li>数据结构可以从逻辑结构和物理结构两个角度进行分类。逻辑结构描述了数据元素之间的逻辑关系,而物理结构描述了数据在计算机内存中的存储方式。</li>
|
||||
<li>常见的逻辑结构包括线性、树状和网状等。通常我们根据逻辑结构将数据结构分为线性(数组、链表、栈、队列)和非线性(树、图、堆)两种。哈希表的实现可能同时包含线性和非线性结构。</li>
|
||||
<li>当程序运行时,数据被存储在计算机内存中。每个内存空间都拥有对应的内存地址,程序通过这些内存地址访问数据。</li>
|
||||
<li>物理结构主要分为连续空间存储(数组)和离散空间存储(链表)。所有数据结构都是由数组、链表或两者的组合实现的。</li>
|
||||
<li>物理结构主要分为连续空间存储(数组)和分散空间存储(链表)。所有数据结构都是由数组、链表或两者的组合实现的。</li>
|
||||
<li>计算机中的基本数据类型包括整数 <code>byte</code>、<code>short</code>、<code>int</code>、<code>long</code> ,浮点数 <code>float</code>、<code>double</code> ,字符 <code>char</code> 和布尔 <code>boolean</code> 。它们的取值范围取决于占用空间大小和表示方式。</li>
|
||||
<li>原码、反码和补码是在计算机中编码数字的三种方法,它们之间是可以相互转换的。整数的原码的最高位是符号位,其余位是数字的值。</li>
|
||||
<li>整数在计算机中是以补码的形式存储的。在补码表示下,计算机可以对正数和负数的加法一视同仁,不需要为减法操作单独设计特殊的硬件电路,并且不存在正负零歧义的问题。</li>
|
||||
|
BIN
chapter_preface/about_the_book.assets/hello_algo_mindmap.jpg
Normal file
BIN
chapter_preface/about_the_book.assets/hello_algo_mindmap.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 KiB |
Binary file not shown.
Before Width: | Height: | Size: 70 KiB |
@ -3345,7 +3345,7 @@
|
||||
<li><strong>数据结构</strong>:基本数据类型,数据结构的分类方法。数组、链表、栈、队列、哈希表、树、堆、图等数据结构的定义、优缺点、常用操作、常见类型、典型应用、实现方法等。</li>
|
||||
<li><strong>算法</strong>:搜索、排序、分治、回溯、动态规划、贪心等算法的定义、优缺点、效率、应用场景、解题步骤、示例题目等。</li>
|
||||
</ul>
|
||||
<p><a class="glightbox" href="../about_the_book.assets/hello_algo_mindmap.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Hello 算法内容结构" src="../about_the_book.assets/hello_algo_mindmap.png" /></a></p>
|
||||
<p><a class="glightbox" href="about_the_book.assets/hello_algo_mindmap.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Hello 算法内容结构" src="about_the_book.assets/hello_algo_mindmap.png" /></a></p>
|
||||
<p align="center"> 图 0-1 Hello 算法内容结构 </p>
|
||||
|
||||
<h2 id="013">0.1.3 致谢<a class="headerlink" href="#013" title="Permanent link">¶</a></h2>
|
||||
|
@ -3439,7 +3439,7 @@
|
||||
</ul>
|
||||
<p><strong>树查找</strong></p>
|
||||
<ul>
|
||||
<li>适用于海量数据,因为树节点在内存中是离散存储的。</li>
|
||||
<li>适用于海量数据,因为树节点在内存中是分散存储的。</li>
|
||||
<li>适合需要维护有序数据或范围查找的场景。</li>
|
||||
<li>在持续增删节点的过程中,二叉搜索树可能产生倾斜,时间复杂度劣化至 <span class="arithmatex">\(O(n)\)</span> 。</li>
|
||||
<li>若使用 AVL 树或红黑树,则各项操作可在 <span class="arithmatex">\(O(\log n)\)</span> 效率下稳定运行,但维护树平衡的操作会增加额外开销。</li>
|
||||
|
File diff suppressed because one or more lines are too long
BIN
sitemap.xml.gz
BIN
sitemap.xml.gz
Binary file not shown.
Loading…
Reference in New Issue
Block a user