diff --git a/chapter_data_structure/data_and_memory.md b/chapter_data_structure/data_and_memory.md index 3fd0b3907..b880ec356 100644 --- a/chapter_data_structure/data_and_memory.md +++ b/chapter_data_structure/data_and_memory.md @@ -2,9 +2,13 @@ comments: true --- -# 3.1. 数据与内存 +--- +comments: true +--- -## 3.1.1. 基本数据类型 +# 3.1. 3.1. 数据与内存 + +## 3.1.1. 3.1.1. 基本数据类型 谈到计算机中的数据,我们能够想到文本、图片、视频、语音、3D 模型等等,这些数据虽然组织形式不同,但都是由各种基本数据类型构成的。 @@ -12,8 +16,8 @@ comments: true - 「整数」根据不同的长度分为 byte, short, int, long ,根据算法需求选用,即在满足取值范围的情况下尽量减小内存空间占用; - 「浮点数」代表小数,根据长度分为 float, double ,同样根据算法的实际需求选用; -- 「字符」在计算机中是以字符集的形式保存的,char 的值实际上是数字,代表字符集中的编号,计算机通过字符集查表来完成编号到字符的转换。占用空间与具体编程语言有关,通常为 2 bytes 或 1 byte ; -- 「布尔」代表逻辑中的“是”与“否”,其占用空间需要具体根据编程语言确定,通常为 1 byte 或 1 bit ; +- 「字符」在计算机中是以字符集的形式保存的,char 的值实际上是数字,代表字符集中的编号,计算机通过字符集查表来完成编号到字符的转换。占用空间通常为 2 bytes 或 1 byte ; +- 「布尔」代表逻辑中的“是”与“否”,其占用空间需根据编程语言确定,通常为 1 byte 或 1 bit ;
Fig. IEEE 754 标准下的 float 表示方式
+Fig. IEEE 754 标准下的 float 表示方式
+ 以上图为例,$\mathrm{S} = 0$ , $\mathrm{E} = 124$ ,$\mathrm{N} = 2^{-2} + 2^{-3} = 0.375$ ,易得 $$ @@ -96,12 +102,16 @@ $$ 进一步地,指数位 $E = 0$ 和 $E = 255$ 具有特殊含义,**用于表示零、无穷大、$\mathrm{NaN}$ 等**。 +Fig. 内存条、内存空间、内存地址
+Fig. 内存条、内存空间、内存地址
+ **内存资源是设计数据结构与算法的重要考虑因素**。内存是所有程序的公共资源,当内存被某程序占用时,不能被其它程序同时使用。我们需要根据剩余内存资源的情况来设计算法。例如,若剩余内存空间有限,则要求算法占用的峰值内存不能超过系统剩余内存;若运行的程序很多、缺少大块连续的内存空间,则要求选取的数据结构必须能够存储在离散的内存空间内。 diff --git a/stylesheets/extra.css b/stylesheets/extra.css index 7171f2ed1..50d33492e 100644 --- a/stylesheets/extra.css +++ b/stylesheets/extra.css @@ -29,14 +29,23 @@ /* Center Markdown Tables (requires md_in_html extension) */ .center-table { - text-align: center; + text-align: center; } +/* Reset alignment for table cells */ .md-typeset .center-table :is(td,th):not([align]) { - /* Reset alignment for table cells */ - text-align: initial; + text-align: initial; } +/* Font size */ +.md-typeset { + font-size: 0.75rem; + line-height: 1.5; +} + +.md-typeset pre { + font-size: 0.95em; +} /* Markdown Header */ /* https://github.com/squidfunk/mkdocs-material/blob/dcab57dd1cced4b77875c1aa1b53467c62709d31/src/assets/stylesheets/main/_typeset.scss */ @@ -72,5 +81,5 @@ body { /* max height of code block */ /* https://github.com/squidfunk/mkdocs-material/issues/3444 */ .md-typeset pre > code { - max-height: 30rem; + max-height: 25rem; }