This commit is contained in:
krahets 2023-03-07 23:59:27 +08:00
parent 400e329554
commit ca17d1bf62
4 changed files with 76 additions and 118 deletions

View file

@ -79,7 +79,7 @@
<div data-md-component="skip">
<a href="#comments-true" class="md-skip">
<a href="#31" class="md-skip">
跳转至
</a>
@ -585,6 +585,8 @@
<label class="md-nav__link md-nav__link--active" for="__toc">
3.1. &nbsp; 数据与内存
<span class="md-nav__icon md-icon"></span>
@ -601,6 +603,8 @@
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
目录
@ -608,26 +612,11 @@
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#comments-true" class="md-nav__link">
comments: true
<a href="#311" class="md-nav__link">
3.1.1. &nbsp; 基本数据类型
</a>
</li>
<li class="md-nav__item">
<a href="#31-31" class="md-nav__link">
3.1. &nbsp; 3.1. &nbsp; 数据与内存
</a>
<nav class="md-nav" aria-label="3.1. &nbsp; 3.1. &nbsp; 数据与内存">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#311-311" class="md-nav__link">
3.1.1. &nbsp; 3.1.1. &nbsp; 基本数据类型
</a>
<nav class="md-nav" aria-label="3.1.1. &nbsp; 3.1.1. &nbsp; 基本数据类型">
<nav class="md-nav" aria-label="3.1.1. &nbsp; 基本数据类型">
<ul class="md-nav__list">
<li class="md-nav__item">
@ -657,15 +646,10 @@
</li>
<li class="md-nav__item">
<a href="#312-312" class="md-nav__link">
3.1.2. &nbsp; 3.1.2. &nbsp; 计算机内存
<a href="#312" class="md-nav__link">
3.1.2. &nbsp; 计算机内存
</a>
</li>
</ul>
</nav>
</li>
</ul>
@ -1687,6 +1671,8 @@
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
目录
@ -1694,26 +1680,11 @@
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#comments-true" class="md-nav__link">
comments: true
<a href="#311" class="md-nav__link">
3.1.1. &nbsp; 基本数据类型
</a>
</li>
<li class="md-nav__item">
<a href="#31-31" class="md-nav__link">
3.1. &nbsp; 3.1. &nbsp; 数据与内存
</a>
<nav class="md-nav" aria-label="3.1. &nbsp; 3.1. &nbsp; 数据与内存">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#311-311" class="md-nav__link">
3.1.1. &nbsp; 3.1.1. &nbsp; 基本数据类型
</a>
<nav class="md-nav" aria-label="3.1.1. &nbsp; 3.1.1. &nbsp; 基本数据类型">
<nav class="md-nav" aria-label="3.1.1. &nbsp; 基本数据类型">
<ul class="md-nav__list">
<li class="md-nav__item">
@ -1743,15 +1714,10 @@
</li>
<li class="md-nav__item">
<a href="#312-312" class="md-nav__link">
3.1.2. &nbsp; 3.1.2. &nbsp; 计算机内存
<a href="#312" class="md-nav__link">
3.1.2. &nbsp; 计算机内存
</a>
</li>
</ul>
</nav>
</li>
</ul>
@ -1778,12 +1744,8 @@
<h1>3.1. &nbsp; 数据与内存</h1>
<hr />
<h2 id="comments-true">comments: true<a class="headerlink" href="#comments-true" title="Permanent link">&para;</a></h2>
<h1 id="31-31">3.1. &nbsp; 3.1. &nbsp; 数据与内存<a class="headerlink" href="#31-31" title="Permanent link">&para;</a></h1>
<h2 id="311-311">3.1.1. &nbsp; 3.1.1. &nbsp; 基本数据类型<a class="headerlink" href="#311-311" title="Permanent link">&para;</a></h2>
<h1 id="31">3.1. &nbsp; 数据与内存<a class="headerlink" href="#31" title="Permanent link">&para;</a></h1>
<h2 id="311">3.1.1. &nbsp; 基本数据类型<a class="headerlink" href="#311" title="Permanent link">&para;</a></h2>
<p>谈到计算机中的数据我们能够想到文本、图片、视频、语音、3D 模型等等,这些数据虽然组织形式不同,但都是由各种基本数据类型构成的。</p>
<p><strong>「基本数据类型」是 CPU 可以直接进行运算的类型,在算法中直接被使用</strong></p>
<ul>
@ -1906,8 +1868,6 @@
<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 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
@ -2029,15 +1989,13 @@
</div>
</div>
</div>
<h2 id="312-312">3.1.2. &nbsp; 3.1.2. &nbsp; 计算机内存<a class="headerlink" href="#312-312" title="Permanent link">&para;</a></h2>
<h2 id="312">3.1.2. &nbsp; 计算机内存<a class="headerlink" href="#312" title="Permanent link">&para;</a></h2>
<p>在计算机中,内存和硬盘是两种主要的存储硬件设备。「硬盘」主要用于长期存储数据,容量较大(通常可达到 TB 级别)、速度较慢。「内存」用于运行程序时暂存数据,速度较快,但容量较小(通常为 GB 级别)。</p>
<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 align="center"> Fig. 内存条、内存空间、内存地址 </p>
<p><strong>内存资源是设计数据结构与算法的重要考虑因素</strong>。内存是所有程序的公共资源,当内存被某程序占用时,不能被其它程序同时使用。我们需要根据剩余内存资源的情况来设计算法。例如,若剩余内存空间有限,则要求算法占用的峰值内存不能超过系统剩余内存;若运行的程序很多、缺少大块连续的内存空间,则要求选取的数据结构必须能够存储在离散的内存空间内。</p>

File diff suppressed because one or more lines are too long

View file

@ -2,257 +2,257 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.hello-algo.com/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_appendix/contribution/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_appendix/installation/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/array/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/linked_list/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/list/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_array_and_linkedlist/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/performance_evaluation/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/space_complexity/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/space_time_tradeoff/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_computational_complexity/time_complexity/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_data_structure/classification_of_data_structure/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_data_structure/data_and_memory/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_data_structure/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_graph/graph/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_graph/graph_operations/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_graph/graph_traversal/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_graph/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_hashing/hash_collision/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_hashing/hash_map/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_hashing/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_heap/build_heap/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_heap/heap/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_heap/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_introduction/algorithms_are_everywhere/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_introduction/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_introduction/what_is_dsa/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_preface/about_the_book/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_preface/suggestions/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_preface/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_reference/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_searching/binary_search/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_searching/hashing_search/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_searching/linear_search/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_searching/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_sorting/bubble_sort/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_sorting/insertion_sort/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_sorting/intro_to_sort/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_sorting/merge_sort/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_sorting/quick_sort/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_sorting/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/deque/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/queue/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/stack/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_stack_and_queue/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_tree/avl_tree/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_tree/binary_search_tree/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_tree/binary_tree/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_tree/binary_tree_traversal/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>https://www.hello-algo.com/chapter_tree/summary/</loc>
<lastmod>2023-03-06</lastmod>
<lastmod>2023-03-07</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>

Binary file not shown.