{"format":"brushup-mindmap-v1","id":"ds-00-sheet6","title":"第七章 查找","structure":"timeline-h","theme":"auto","root":{"id":"087852e6974916e5c330fae35d","topic":"第七章 查找","expanded":false,"children":[{"id":"1fe98c3d2a3a4c49238ccbff04","topic":"概念","expanded":true,"children":[{"id":"95887c33be3934c736e42815aa","topic":"查找表","expanded":true,"children":[{"id":"fb89659e0e4b98735c7729706a","topic":"支持查、增、删","expanded":true}]},{"id":"be1b7429859b6506c63edb4907","topic":"静态查找表","expanded":true,"children":[{"id":"bf4952cff5f871671f74d9b6bf","topic":"只支持查","expanded":true}]},{"id":"bf2a6f1bf638640eef29b878f4","topic":"关键字","expanded":true,"children":[{"id":"da59f771aed902b5eaa02ab522","topic":"key words，具有唯一标示性","expanded":true,"children":[{"id":"242b248563292e8d43e178054f","topic":"例如：学号、身份证号","expanded":true}]},{"id":"0d8ae3d4-c8db-4178-9801-9c57becf7412","topic":"使用关键字来查找记录，记录可能非常大（4B—100GB）","expanded":true}]},{"id":"33fb11f3f5fb28c33aafca5bd6","topic":"查找的【平均查找长度】","expanded":true,"children":[{"id":"b4ba65c1c2cb10975a538897bd","topic":"ASL","expanded":true,"children":[{"id":"2cc82051d618a8166e0168099c","topic":"成功","expanded":true},{"id":"828bfdac214b3818bd8c3912d8","topic":"失败","expanded":true}]},{"id":"457b8bd2bb89870ec77c09818f","topic":"而不是用时间复杂度","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]}]},{"id":"de1883beb818b83933d668c4a0","topic":"顺序查找","expanded":true,"children":[{"id":"2689b06f-ba49-48c8-8a60-b1714bfcd184","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"9f4218c1-2b6c-4d48-be18-332840ffa114","topic":"无","expanded":true}]},{"id":"c6caf511e2cb9de2ec8748cf54","topic":"顺序查找一般会设置 a[0] 为哨兵位","expanded":true,"children":[{"id":"a01bdf2f-b093-4b98-931e-5582ede4ed30","topic":"在创建数据结构的时候就把a[0]留出来","expanded":true},{"id":"263814fa-0173-41f6-8563-048171cae24d","topic":"这样查找返回值可以用unsigned int了，否则没找到返回-1，结果是int，很大空间都不用到。","expanded":true,"children":[{"id":"c0cdeb2e-3fba-459d-9fe2-a8f4885a64ea","topic":"int：（-32768～32767）","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]}]},{"id":"aa89e759a31b57fad738680c2f","topic":"一般表","expanded":true,"children":[{"id":"39aad0815e5830fbdce8ca235b","topic":"ASL","expanded":true,"children":[{"id":"2d1b037d550a9d9add07799fb8","topic":"成功","expanded":true,"children":[{"id":"385a8f49648b59fb0bcaeafb5c","topic":"ASL 公式","expanded":true,"formula":{"tex":"\\frac{1}{n} \\times 1 + \\frac{1}{n} \\times 2 + \\dots + \\frac{1}{n} \\times n = \\frac{n+1}{2}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mfrac><mn>1</mn><mi>n</mi></mfrac><mo>×</mo><mn>1</mn><mo>+</mo><mfrac><mn>1</mn><mi>n</mi></mfrac><mo>×</mo><mn>2</mn><mo>+</mo><mo>⋯</mo><mo>+</mo><mfrac><mn>1</mn><mi>n</mi></mfrac><mo>×</mo><mi>n</mi><mo>=</mo><mfrac><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow><mn>2</mn></mfrac></mrow><annotation encoding=\"application/x-tex\">\\frac{1}{n} \\times 1 + \\frac{1}{n} \\times 2 + \\dots + \\frac{1}{n} \\times n = \\frac{n+1}{2}</annotation></semantics></math></span>"}}]},{"id":"6f1aeae9a299fa202992c8eefb","topic":"失败","expanded":true,"children":[{"id":"94192883b9883c4d6b357aac0f","topic":"ASL","expanded":true,"children":[{"id":"2e085c7f68ba4ef879d798e221","topic":"因为必须全部搜索一遍","expanded":true}],"formula":{"tex":"n + 1","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow><annotation encoding=\"application/x-tex\">n + 1</annotation></semantics></math></span>"}}]}]}]},{"id":"744bce9014abc0ddfd93a811c0","topic":"有序表","expanded":true,"children":[{"id":"d398fa6a4c486b560932693465","topic":"ASL","expanded":true,"children":[{"id":"2dba6a5049e9e52c591c2a635e","topic":"成功","expanded":true,"children":[{"id":"bc18f7f7610b2b2f5a7aca7277","topic":"ASL 公式","expanded":true,"formula":{"tex":"\\frac{1}{n} \\times 1 + \\frac{1}{n} \\times 2 + \\dots + \\frac{1}{n} \\times n = \\frac{n+1}{2}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mfrac><mn>1</mn><mi>n</mi></mfrac><mo>×</mo><mn>1</mn><mo>+</mo><mfrac><mn>1</mn><mi>n</mi></mfrac><mo>×</mo><mn>2</mn><mo>+</mo><mo>⋯</mo><mo>+</mo><mfrac><mn>1</mn><mi>n</mi></mfrac><mo>×</mo><mi>n</mi><mo>=</mo><mfrac><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow><mn>2</mn></mfrac></mrow><annotation encoding=\"application/x-tex\">\\frac{1}{n} \\times 1 + \\frac{1}{n} \\times 2 + \\dots + \\frac{1}{n} \\times n = \\frac{n+1}{2}</annotation></semantics></math></span>"}}]},{"id":"8dfb421d08689b1f6c65b8b877","topic":"失败","expanded":true,"children":[{"id":"6278dd45863980c544cd09e07c","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-58cd8fa124b5d2.png","width":864,"height":662},"children":[{"id":"6e13b8fc-0fc9-49b2-a971-fd54cdb71a74","topic":"n 个结点 → n+1 种失败情况 → 每个概率相同","expanded":true,"formula":{"tex":"\\frac{1}{n+1} + \\frac{2}{n+1} + \\dots + \\frac{n}{n+1} \\times 2 = \\frac{n}{2} + \\frac{n}{n+1}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mfrac><mn>1</mn><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></mfrac><mo>+</mo><mfrac><mn>2</mn><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></mfrac><mo>+</mo><mo>⋯</mo><mo>+</mo><mfrac><mi>n</mi><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></mfrac><mo>×</mo><mn>2</mn><mo>=</mo><mfrac><mi>n</mi><mn>2</mn></mfrac><mo>+</mo><mfrac><mi>n</mi><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></mfrac></mrow><annotation encoding=\"application/x-tex\">\\frac{1}{n+1} + \\frac{2}{n+1} + \\dots + \\frac{n}{n+1} \\times 2 = \\frac{n}{2} + \\frac{n}{n+1}</annotation></semantics></math></span>"}}]}]}]}]}]},{"id":"909a0ebf2fdae3b0e5a13afe9c","topic":"二分查找","expanded":true,"children":[{"id":"a0693b77c10852e83dc86b11c4","topic":"折半查找，前提是一个有序顺序表","expanded":true,"children":[{"id":"8eca8671fc6b076b284b980ee1","topic":"无序的、链式的都不可以","expanded":true}]},{"id":"ed98e1bb5b7a495de24c1b36a9","topic":"ASL","expanded":true,"children":[{"id":"5b2999120d8889931477786666","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4be61959386d5a.png","width":271,"height":132},"children":[{"id":"b5b95fc9eb0afcd39f7e89c20b","topic":"查找成功","expanded":true,"children":[{"id":"44c94b20c7d911437fbf7bdb8e","topic":"","expanded":true,"formula":{"tex":"ASL = \\frac{1}{11} \\times (1 + 2 \\times 2 + 3 \\times 4 + 4 \\times 4) = 3.3","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>A</mi><mi>S</mi><mi>L</mi><mo>=</mo><mfrac><mn>1</mn><mn>11</mn></mfrac><mo>×</mo><mo stretchy=\"false\">(</mo><mn>1</mn><mo>+</mo><mn>2</mn><mo>×</mo><mn>2</mn><mo>+</mo><mn>3</mn><mo>×</mo><mn>4</mn><mo>+</mo><mn>4</mn><mo>×</mo><mn>4</mn><mo stretchy=\"false\">)</mo><mo>=</mo><mn>3.3</mn></mrow><annotation encoding=\"application/x-tex\">ASL = \\frac{1}{11} \\times (1 + 2 \\times 2 + 3 \\times 4 + 4 \\times 4) = 3.3</annotation></semantics></math></span>"}}]},{"id":"7a690337e00b050a14976ac6d3","topic":"查找失败","expanded":true,"children":[{"id":"0328a5bf45e9117938db18eb28","topic":"","expanded":true,"style":{"fontWeight":"bold"},"formula":{"tex":"ASL = \\frac{1}{12} \\times (3 \\times 4 + 8 \\times 4) = 3.7","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>A</mi><mi>S</mi><mi>L</mi><mo>=</mo><mfrac><mn>1</mn><mn>12</mn></mfrac><mo>×</mo><mo stretchy=\"false\">(</mo><mn>3</mn><mo>×</mo><mn>4</mn><mo>+</mo><mn>8</mn><mo>×</mo><mn>4</mn><mo stretchy=\"false\">)</mo><mo>=</mo><mn>3.7</mn></mrow><annotation encoding=\"application/x-tex\">ASL = \\frac{1}{12} \\times (3 \\times 4 + 8 \\times 4) = 3.7</annotation></semantics></math></span>"}}]}]}]},{"id":"cf8826c1382bb941d8e6694efe","topic":"凡是有序、可随机访问的查找表，都可以进行二分查找","expanded":true,"style":{"background":"#FFABD5"}},{"id":"7794584c-9730-4efb-aa0f-c21b68d58348","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"fb57dad5-150b-4fae-a9cd-d53573031a48","topic":"10、15、16、17、13大","expanded":true}]}]},{"id":"2019f3a7473a726fe624cb0c27","topic":"分块查找","expanded":true,"children":[{"id":"67ee91f0-6e48-4758-9924-5b24e36d73b2","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"fd17f549-d730-4f5c-ae94-ae82966bf201","topic":"无","expanded":true}]},{"id":"4739515a772b73e93931285ef1","topic":"分块/索引查找","expanded":true,"children":[{"id":"cd38ec898e4b2021b1b80832ad","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b52be65f840570.png","width":407,"height":124},"children":[{"id":"87d9e5281d49f59b47239a9406","topic":"索引查找表平均查找长度 Li","expanded":true,"children":[{"id":"53e90b0e92cad70932a31a0aa7","topic":"块内查找表平均查找长度Ls","expanded":true}]},{"id":"ca5925830b8a9a10ff436b2ee0","topic":"查找成功","expanded":true,"children":[{"id":"3699b3917e1acb78683d3904e6","topic":"ASL = Li + Ls","expanded":true}]},{"id":"6f5aff740cebb737a2b97b23fb","topic":"查找失败","expanded":true,"children":[{"id":"937b2a0a652b911b042a8b87b1","topic":"ASL = Li + (Ls + 1)","expanded":true}]},{"id":"10afbf17-3051-450b-9894-bdd2505f9bb3","topic":"Li的具体值：顺序/二分","expanded":true,"children":[{"id":"74b7ceee-da97-4949-9274-9ddf1a3f7dc3","topic":"Ls的具体值：只能顺序","expanded":true}]}]},{"id":"da1bedc208e9fcae0c6ada4c71","topic":"用于OS中分块存储","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]},{"id":"517b6afe659b88f0db72287406","topic":"这个在索引表内部仍然可以采用二分的方法进行加速","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"00635cf0-cd53-4c58-83bc-d03dc18bcabe","topic":"有序的顺序表都可以（___ ___ ___ ___）","expanded":true}]}]},{"id":"6b85015e-a4b6-4e00-90c6-a4269456b8a1","topic":"树形查找","expanded":true,"children":[{"id":"3b0637f6-4fd3-42d9-a5a5-c74a2721beef","topic":"二叉排序树","expanded":true,"children":[{"id":"8cdebe52-d9b2-4582-b177-e7dc4879cad0","topic":"见第五章：树","expanded":true}]},{"id":"248e402c-4b68-43b2-9949-ba11211b8a54","topic":"平衡二叉树","expanded":true,"children":[{"id":"b7273aad-6b34-40b7-8232-9555e3fd499b","topic":"见第五章：树","expanded":true}]},{"id":"8ece76b9-d5e5-4676-bf90-fa34b3f3a6ac","topic":"红黑树","expanded":true,"children":[{"id":"1fd9c56a-1f7c-4c50-9119-8d2a1268eff0","topic":"各种树的历史","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-69ce9a78d7c03e.png","width":651,"height":126}},{"id":"3d1b9959-94f6-4558-8054-5c411b90fc6e","topic":"发明的原因：","expanded":true,"children":[{"id":"262229e3-c0f9-44d8-a85b-5ea6435f53d4","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d99ee704c09343.png","width":417,"height":175},"children":[{"id":"5fd56882-f122-4fc5-b0f0-79c35d77ff82","topic":"平衡二叉树 AVL：进行插入/删除时很容易破坏“平衡”特性，需要频繁调整树的形态。如:插入操作导致不平衡，则需要先计算平衡因子，找到最小不平衡子树(时间开销大)，再进行LL/RR/LR/RL 调整。","expanded":true,"children":[{"id":"75d5d214-abd1-4a12-bf91-5ad15ddbed02","topic":"适用于以查为主、很少插入/删除的场景","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"2e8cdb7a-dce8-4503-8710-1c9bba829d20","topic":"红黑树 RBT：插入/删除 很多时候不会破坏“红黑”特性，无需频繁调整树的形态。即便需要调整，一般都可以在常数级时间内完成。","expanded":true,"children":[{"id":"106a9242-22ad-46f0-9868-1a0dfee5b86c","topic":"适用于频繁插入、删除的场景，实用性更强","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"eabdaa32-ee38-48d5-91f1-0e0051338096","topic":"考的方向：","expanded":true,"children":[{"id":"312c83cf-cfcb-44dc-9ac0-b477a36fab4c","topic":"选择题 --- 定义、性质","expanded":true,"children":[{"id":"79d5d18c-bf7f-496b-8df2-8510f65bc71a","topic":"类似","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-e1536259b58052.png","width":487,"height":154}}]},{"id":"e6310250-1761-4e11-90ad-27d5a1bd1dea","topic":"插入（删除） --- 手绘","expanded":true,"children":[{"id":"6d099f16-134d-4865-9762-832aaaabe26a","topic":"类似","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f7b70375cf069e.png","width":483,"height":103}}]}]},{"id":"cb28c0d2-7426-4768-a0d7-8adca824949a","topic":"红黑树的定义","expanded":true,"children":[{"id":"4fdc5da7-d9cc-4992-b761-0ca28075582a","topic":"左根右，跟叶黑，不红红，黑路同","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-577d2a831b80a8.png","width":494,"height":226},"children":[{"id":"67af1552-2eda-4ef4-b621-319640d8b486","topic":"出题思路","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8bea96e5d08caa.png","width":423,"height":233}}]}]},{"id":"cc1e7719-d4e2-4c5b-bcdf-0cb4cc0917b2","topic":"概念：黑高 bh","expanded":true,"children":[{"id":"e17d918f-f983-4d15-8465-411ba1518c74","topic":"结点的黑高 bh ：从某结点出发(不含该结点)到达任一空叶结点的路径上黑结点总数","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-795e4bfea6ff93.png","width":330,"height":227},"children":[{"id":"1db79de6-7341-46b9-b46e-286415de9990","topic":"性质 1：","expanded":true,"children":[{"id":"2556b8a1-0ff0-4a0a-8b63-09f8ff3775d2","topic":"从根节点到叶子节点的最长路径不大于最短路径的2倍","expanded":true}]},{"id":"0d9670bf-b185-4782-958a-9b637fe3c2c5","topic":"性质 2：","expanded":true,"children":[{"id":"17e9574a-1932-4e3c-98a2-f0756ab68a58","topic":"有 n 个内部结点的红黑树的树高","expanded":true,"formula":{"tex":"h \\le 2\\log_2(n + 1)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>h</mi><mo>≤</mo><mn>2</mn><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mo stretchy=\"false\">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">h \\le 2\\log_2(n + 1)</annotation></semantics></math></span>"}}]}]}]},{"id":"79370853-371a-47e5-818e-30110b9ddb8f","topic":"基本操作：","expanded":true,"children":[{"id":"b4a4b5dc-6c18-4a56-8a59-8ad76b340fc9","topic":"查找：","expanded":true,"children":[{"id":"723b0735-d36c-41b6-b303-fb7d4aa00dc7","topic":"与 BST、AVL 相同，从根出发，左小右大，若查找到一个空叶节点，则查找失败","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-732e14091f9829.png","width":316,"height":145}}]},{"id":"9db22cf0-edb1-401c-af74-61f64eab769e","topic":"插入：","expanded":true,"children":[{"id":"3f63b1d7-1db5-40af-b0e1-e31d39f261c0","topic":"插入策略：","expanded":true,"children":[{"id":"ac0ef846-98c2-41e0-83da-e9dbf21839bc","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ac8e25a5dfa591.png","width":591,"height":400}}]},{"id":"cca23b4e-f4b7-42f0-946f-a0d202c31003","topic":"插入练习","expanded":true,"children":[{"id":"ec0706dc-0c0a-440a-9707-141aef26d993","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-61ff95dea142c6.png","width":843,"height":563}}]}]}]},{"id":"e51c9a28-5b19-4224-8565-51b46be2b32a","topic":"重要性质","expanded":true,"children":[{"id":"9a532a0b-0c16-4819-81b6-4a8083812f0f","topic":"1. 与AVL的比较","expanded":true,"children":[{"id":"956c4f3b-a734-4886-8af3-abb5563bb4ec","topic":"RBT和AVL的时间复杂度都是相同的，但是平均来讲，RBT的插入删除快一些（复杂度相同）","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"7cfd76bc-f66f-4f88-8030-81c9c6193678","topic":"2. 旋转次数","expanded":true,"children":[{"id":"f1262896-b423-40ea-a96c-93f45e25e12c","topic":"2021年的提问：红黑树的旋转调整一定是在3次以内完成的","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ba4fe37855efc4.png","width":643,"height":137}}]}]}]},{"id":"ffbcc535-82d1-4e23-8712-9f3707f9169f","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"29270bd6-a5e5-4259-88c6-f07a53a7e6d0","topic":"09-12、13*2、15、18-21","expanded":true}]}]},{"id":"c11af5ab122aff80c4bdf9ad07","topic":"B树","expanded":true,"children":[{"id":"4d785131-f927-4de9-8488-4d289db2273a","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"9ec1ee1b-d17a-4138-a1b8-12356a7755b5","topic":"09、12-14、17、18、20-22","expanded":true}]},{"id":"f1d9a7c750db01a0d2c5e88f8b","topic":"B树","expanded":true,"children":[{"id":"9c19880529fa3c9aef791b0817","topic":"定义","expanded":true,"children":[{"id":"bd8ba26d11d881cadf60e95bc3","topic":"B 树，又称多路平衡查找树，B 树中所有结点的孩子个数的最大值称为 B 树的阶，通常用 m 表示。一棵 m 阶 B 树要么是空树，要么满足这些特性：","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1cab2f1d0ef051.png","width":484,"height":184},"children":[{"id":"85254efc-9aa8-4bba-9a0d-95ad24e9e955","topic":"1) 树中每个结点至多有m棵子树，即至多含有m-1个关键字。","expanded":true},{"id":"e43a0c9b-7416-4a90-9858-83a83f27f78f","topic":"2) 若根结点不是终端结点，则至少有两棵子树。","expanded":true},{"id":"b0ee4d9b-97e6-4bb7-b985-f057430c75b9","topic":"3) 除根结点外的所有非叶结点至少有⌈m/2⌉棵子树，即至少含有⌈m/2⌉-1个关键字。","expanded":true},{"id":"4f8cc7c4-e1bb-45f6-8f92-80fbd014987a","topic":"4) 所有的叶结点都出现在同一层次上，并且不带信息（可以视为外部结点或类似于折半查找判定树的查找失败结点，实际上这些结点不存在，指向这些结点的指针为空)。","expanded":true}]}]},{"id":"fbfa7f3591ba3084879e488029","topic":"数据\n结构","expanded":true,"children":[{"id":"8008782f4d883e157517b9e7bf","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f2fbe6b434e3e9.png","width":380,"height":133}}]}]},{"id":"b19b4440b52bcd99e48c5a8c8d","topic":"是一种BST的拓展","expanded":true,"children":[{"id":"60ab4a6258aab8dd34651a9a5a","topic":"多叉查找树","expanded":true,"children":[{"id":"b4fa0439640a577297fe08b603","topic":"BST每次把搜索域分为两个部分，B树把搜索域分为m个部分","expanded":true}]},{"id":"40f9f55245f8130a631808d45f","topic":"例：","expanded":true,"children":[{"id":"137837972f79a90004158ac7f2","topic":"五叉查找树","expanded":true,"children":[{"id":"781ae75f118b8f0be5964bacbd","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0a41b66be57a35.png","width":403,"height":186},"children":[{"id":"fb081ece3c2862e0a27e0b19fb","topic":"例：查9","expanded":true,"children":[{"id":"09ba93a273c8ee6b993bc8cd66","topic":"22 -> 5 -> 6 -> 8 -> 9","expanded":true}]},{"id":"33f88e231628f85d5b0959fd22","topic":"例：查41","expanded":true,"children":[{"id":"88f829f0642bce072b52cab1cc","topic":"22 -> 36 -> 40 -> 42 -> 失败","expanded":true}]}]},{"id":"f64a635fe8abb4b216d87ad686","topic":"tint:有序、\n可随机访问哦","expanded":true,"icons":["emoji:💬"],"style":{"background":"#FFABD5","borderStyle":"dashed","borderColor":"#F59E0B"}}]}]}]},{"id":"b7a9bb6468c98d1cf91979068b","topic":"如何保证m叉查找树效率够高","expanded":true,"children":[{"id":"536a5d52327b41e6407d1bcf46","topic":"策略一：","expanded":true,"children":[{"id":"cad80d16e558f94ce135e9580b","topic":"m叉查找树，除了根节点以外任何结点都至少要有⌈m/2⌉个分叉，则至少有⌈m/2⌉ - 1 个关键字","expanded":true},{"id":"dc49916f-1039-4c7d-a59e-48f741090274","topic":"如何记住⌈m/2⌉ - 1：考虑分裂吧，分裂也是从⌈m/2⌉ 处分的","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f03f46d7e02aae.png","width":296,"height":123}}]},{"id":"6e4ab64a131b15e5751078d8b7","topic":"策略二：","expanded":true,"children":[{"id":"2779dd9d30499f765f5f181039","topic":"任何一个节点，其所有的子树高度都要相同","expanded":true}]}]},{"id":"5bdb1f8198b8d70bd97658452b","topic":"B树的高度","expanded":true,"children":[{"id":"123a0e26f59a9f0712f869d132","topic":"n个关键字的m阶B树，最大最小高度","expanded":true,"children":[{"id":"e65a2bff6ee81370c86f48716e","topic":"注：B树的高度不包括叶子结点（失败节点）","expanded":true,"style":{"background":"#FF9595"}}]},{"id":"1af821bad1da0b6a41b3a83bc2","topic":"最小：","expanded":true,"children":[{"id":"92788679c9d8127a9a554a948d","topic":"节点填满：(m-1)(1+m+m^2+...+m^h-1) >= n","expanded":true,"children":[{"id":"339116ac-d7d9-4086-a27f-2759d565538a","topic":"每层最多m个指针P，每个P指向的非叶结点最多有(m-1)个关键字K。第i层关键字最多有 ↑。","expanded":true,"formula":{"tex":"(m - 1) * m^{i-1}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mo stretchy=\"false\">(</mo><mi>m</mi><mo>−</mo><mn>1</mn><mo stretchy=\"false\">)</mo><mo>∗</mo><msup><mi>m</mi><mrow><mi>i</mi><mo>−</mo><mn>1</mn></mrow></msup></mrow><annotation encoding=\"application/x-tex\">(m - 1) * m^{i-1}</annotation></semantics></math></span>"}}],"formula":{"tex":"h \\ge \\log_m(n + 1)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>h</mi><mo>≥</mo><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mi>m</mi></msub><mo stretchy=\"false\">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">h \\ge \\log_m(n + 1)</annotation></semantics></math></span>"}}]},{"id":"84e86d94d5285ba0242cc9aa4b","topic":"最大：","expanded":true,"children":[{"id":"d5ebb3a8b5c9f0254a860b6e0c","topic":"根节点2个分叉，其他节点只有⌈m/2⌉个指针","expanded":true,"children":[{"id":"231c8d80-5bfa-4b5e-beae-05474d77828d","topic":"每层最少⌈m/2⌉个指针P，每个P指向的非叶结点最少有⌈m/2⌉-1个关键字K，因此第i层的关键字最少有 ↑。","expanded":true,"formula":{"tex":"(\\lceil m/2 \\rceil - 1) * \\lceil m/2 \\rceil^{i-1}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mo stretchy=\"false\">(</mo><mo stretchy=\"false\">⌈</mo><mi>m</mi><mi mathvariant=\"normal\">/</mi><mn>2</mn><mo stretchy=\"false\">⌉</mo><mo>−</mo><mn>1</mn><mo stretchy=\"false\">)</mo><mo>∗</mo><mo stretchy=\"false\">⌈</mo><mi>m</mi><mi mathvariant=\"normal\">/</mi><mn>2</mn><msup><mo stretchy=\"false\">⌉</mo><mrow><mi>i</mi><mo>−</mo><mn>1</mn></mrow></msup></mrow><annotation encoding=\"application/x-tex\">(\\lceil m/2 \\rceil - 1) * \\lceil m/2 \\rceil^{i-1}</annotation></semantics></math></span>"}}]},{"id":"6c4bb355055b40ade6193a4703","topic":"算法一（会用此方法推算）","expanded":true,"icons":["star:orange"],"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-e60f2994c7ef2d.png","width":318,"height":256},"children":[{"id":"0ffbdd9896faf783ea7ee8d1cc","topic":"算法二","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-e5c8c57a7a4f9b.png","width":414,"height":136}}]}]},{"id":"7948474c252861616d83aaaa56","topic":"高度区间：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"5589e2b5bca8ca497f5d9b0ca9","topic":"","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"1d2d0aec-7147-4eb6-8433-1b87c71b1e39","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8848b9a9c4cbd7.png","width":346,"height":282},"children":[{"id":"dd3bb441ae18dd4b0b0f0b4d46","topic":"左边：一共n个节点，有n+1个查找区间，每次m叉的进行查找，就是以m为底的log","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"0f8a5a65e75940c935cfbb6e46","topic":"右边：注意与左边的区别","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c07babfb49e881ef8216cadfd8","topic":"1. 根节点只有一个节点，所以对n+1进行/2操作，首先将查找区间分成两个部分","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"e0b8c36788bbcb975d44588ac2","topic":"2. 所以h的高度默认就应该带上根节点那层，即整个式子 +1","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"da888eeb3c29b478a17958fec6","topic":"3. 每个结点都是⌈m/2⌉叉，故对(n+1)/2进行如此分叉查找，即以此为底","expanded":true,"style":{"background":"#8EDDF9"}}]}]}],"formula":{"tex":"\\log_m(n + 1) \\le h \\le \\log_{\\lceil m/2 \\rceil} \\frac{n + 1}{2} + 1","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mi>m</mi></msub><mo stretchy=\"false\">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy=\"false\">)</mo><mo>≤</mo><mi>h</mi><mo>≤</mo><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mrow><mo stretchy=\"false\">⌈</mo><mi>m</mi><mi mathvariant=\"normal\">/</mi><mn>2</mn><mo stretchy=\"false\">⌉</mo></mrow></msub><mfrac><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow><mn>2</mn></mfrac><mo>+</mo><mn>1</mn></mrow><annotation encoding=\"application/x-tex\">\\log_m(n + 1) \\le h \\le \\log_{\\lceil m/2 \\rceil} \\frac{n + 1}{2} + 1</annotation></semantics></math></span>"}}]}]},{"id":"7d7a3404392bef8e9321e91c47","topic":"B树的操作","expanded":true,"icons":["star:red"],"style":{"background":"#FDD834","borderColor":"#111111"},"children":[{"id":"f799a2cf955bb87b17835bdeb8","topic":"插入","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"f20b178a2aca5f63051ad98f29","topic":"插入到【终端节点】，【插满了】就从中间⌈m/2⌉ 分裂，分裂的结点送到父节点中去","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-11178ad39f00f8.png","width":443,"height":127},"children":[{"id":"dae24adb-ea91-43a9-94f0-faca62be2ccb","topic":"第一次分裂","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c9e113c2a4a19b.png","width":520,"height":98}},{"id":"ff6f41a7-4990-46b2-a7e3-f313be7fa066","topic":"第二次分裂","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-9e4334a60a01cb.png","width":516,"height":151}}]}]},{"id":"31bb35bec1c91450e402fa4f9a","topic":"删除","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"76aa025b-41b9-4886-8fd4-de3306eca19a","topic":"够删","expanded":true,"children":[{"id":"e59846881d09011c423ef84b16","topic":"删终端","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"aa7a5cd500c819228a2cf8cab9","topic":"直接删","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-878fe254545a50.png","width":401,"height":125},"children":[{"id":"9c604e9f-c8f4-451c-9b99-5fc7a6fe8323","topic":"若被删除关键字在终端节点，则直接删除该关键字 (要注意节点关键字个数是否低于下限⌈m/2⌉ -1)","expanded":true}]}]},{"id":"03583504307b3a2d8a604a17c5","topic":"删非终端","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"1a7a13e462bbd5d8b83e6b57cc","topic":"找直接前驱或直接后继来进行顶替","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-9a724141e89859.png","width":414,"height":124},"children":[{"id":"76587b8582d828f8ff2fb94773","topic":"若被删除关键字在非终端节点，则用直接前驱或直接后继来替代被删除的关键字\n（直接前驱：当前关键字左侧指针所指子树中“最右下”的元素）","expanded":true}]}]}]},{"id":"bbd9d668ba0a3ea1c478ab5359","topic":"删终端后低于下限了","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b2bb102efd3a8f759aa00a52e7","topic":"1. 兄弟够借","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"cc798e6a0f1bf10ca2ff6a11d4","topic":"借右：借后继和后继的后继","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3ca902c130c995d9b0eb7948c9","topic":"借前","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4b83624fda720e.png","width":273,"height":94},"children":[{"id":"bdea054395da4222e272c8b99a","topic":"借后","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-58a09ba54f7243.png","width":270,"height":105}}]}]},{"id":"15189737c17934c53afe1afd2b","topic":"借左：借前驱和前驱的前驱","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"05b94cfed5a927deaf5d090767","topic":"借前","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0da61ad9cdec83.png","width":276,"height":99},"children":[{"id":"fe6b7b0c4dda510af887f9e15a","topic":"借后","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d8e6c1225ad23a.png","width":272,"height":100}}]}]}]},{"id":"5ca9b843f4181fa46a8a699901","topic":"2. 兄弟不够借：兄弟合并","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"e1a85344317900052fd74b5f84","topic":"合并前","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1977568264932c.png","width":403,"height":174},"children":[{"id":"d079e7e68f4b6116fc7f3befc0","topic":"合并后","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2bfa035b4be14d.png","width":439,"height":169},"children":[{"id":"27fb6bd96b3bf1f9d4040a679a","topic":"此时在进行一次合并","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f530e32f59e94e.png","width":428,"height":176}}]}]}]}]}]}]},{"id":"8f1b759acaa8fee00207e91859","topic":"是二叉查找的一种升级优化，重点是查是否有某个值","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"431addd5a269beabaabf197375","topic":"或者把其记录理解为这样","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-457ff4f38e2cbd.png","width":287,"height":134}}]},{"id":"0128f95f2e8b5e2c8e250b79fe","topic":"应用：用B树来做文件索引","expanded":true,"children":[{"id":"37ead7db0658cb0b63184a685f","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c475a1209b51f6.png","width":455,"height":115},"children":[{"id":"e3bb86d0eb5af9859cbc8b27be","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4bedb2379a8c9d.png","width":380,"height":363}}]}]}]},{"id":"720890b661ab7dd3fe9529dfb8","topic":"B+树","expanded":true,"children":[{"id":"7b5a074b610ba9821fd80bb66f","topic":"是分块查找的一种升级优化，作用是查某个对应关键字的记录信息","expanded":true,"style":{"background":"#BA69C8"}},{"id":"8d59b36fbb6a6106d5a569688f","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-cff426caeefa6c.png","width":467,"height":211},"children":[{"id":"17baa3cb1c7b97b9858fb97125","topic":"里面的分支、叶子结点都是包含有多个数据项的一个总结点","expanded":true},{"id":"a99b2081b238e97f591bb821e3","topic":"B树的指针是在结点数据之间的，B+树的指针就是结点数据的一个部分","expanded":true}]},{"id":"8a88c23a8b09fea5e33bd9514a","topic":"m阶B+树的性质","expanded":true,"children":[{"id":"0fcb8066d00b85f71c06badb89","topic":"1. 每个结点最多有m个子树","expanded":true},{"id":"5e8bd7a9ad0a9dd065251b28d4","topic":"2. 非叶根节点至少有两颗子树，其他每个分支至少有⌈m/2⌉颗子树","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2697d1a7a256d8.png","width":358,"height":154},"children":[{"id":"b58b898605eb2c836a836900f7","topic":"B树的叶子结点是最后那一层空的结点，树的最低层的结点是终端结点","expanded":true},{"id":"c8b96ee75108add4748cda0e89","topic":"B+树的叶子结点就是最底层的节点","expanded":true}]},{"id":"0dda385e793b332185b5f9540a","topic":"3. B+树有多少个结点就有多少个分支","expanded":true},{"id":"2a2978a52c0929fa4309793e08","topic":"4. 叶子结点包含有全部的关键字，以及【对应着相应记录的指针】。相邻叶子会被互相连接起来","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-77bfd204b877b4.png","width":364,"height":74},"children":[{"id":"7028a55f716aea683355db2096","topic":"可以顺序查找，可以树形分块查找","expanded":true}]},{"id":"5428d0cdc969813bd44219fed6","topic":"5. 分支节点只包含对应分支的【最大值】","expanded":true}]},{"id":"b95a78631b9890bd4b5368e4fe","topic":"B+的查找","expanded":true,"children":[{"id":"65cbebeaf789e251c7558bcfdf","topic":"多路查找","expanded":true,"children":[{"id":"f159e6a896b85be74293da17c0","topic":"一定需要找到最下一层才可以","expanded":true,"children":[{"id":"1d08adf62a8940f17febc83f5f","topic":"B树可能在任何一层查找成功，只能在其叶子结点查找失败","expanded":true}]}]},{"id":"60281f6bb5f93d29b3d3ba366f","topic":"顺序查找","expanded":true,"children":[{"id":"cf894bec-397a-40ec-9b10-6c536b1f1a80","topic":"可以最后一行全部进行二分查找吗？不行","expanded":true}]}]},{"id":"265804ab9c3b137914ff48198b","topic":"B树和B+树的对比","expanded":true,"children":[{"id":"6a69f7690d0bce04cb364901ad","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-81f251a4f77a67.png","width":506,"height":239}}]},{"id":"81fbcc78f638b07b10f7f90733","topic":"B+的增删操作和B树类似","expanded":true},{"id":"0deb8e04574b767002148a2141","topic":"与OS的联系","expanded":true,"children":[{"id":"6e8acc06c0c8eac9f02f69af3a","topic":"B+树可以用来进行磁盘块的管理","expanded":true,"children":[{"id":"cdd94799786824c1a4c1fb23b9","topic":"磁盘中的磁盘块号就是B+树中的一个结点编号，磁盘块中的数据就是结点记录","expanded":true}]},{"id":"150b1fcb4f386c8e0274983892","topic":"访问：","expanded":true,"children":[{"id":"46b90c871baa990f08da2b3e0d","topic":"计算机去访问根节点的磁盘块，然后逐层往下去进行结点的访问","expanded":true,"children":[{"id":"d6fa6853ac7953b9b2d7295c44","topic":"每个结点都是存在一个磁盘块中，例如磁盘块的大小为1KB，一个结点指针为1B，一个块中有1024个节点指针，故为1024叉B+树","expanded":true}]}]}]},{"id":"e4675e12-9a92-4e6d-9da1-ae68244491d5","topic":"拓展：公司的数据库真正实现的时候，为什么不用红黑树，而是用B+树？","expanded":true,"children":[{"id":"22d9fb6d-3860-4657-8b1e-b55a92e0ff8e","topic":"索引的数据结构会被存储在磁盘中，每次查询都需要到磁盘中访问，对于红黑树，树的高度可能会非常的高，会进行很多次的磁盘IO，效率会非常低，B+树的高度一般为2-4，也就是说在最坏的条件下，也最多进行2到4次磁盘IO，这在实际中性能时非常不错的","expanded":true}]},{"id":"55a3ff92-33f8-4eff-b97d-1c8e7c279c62","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a7732d75-91a4-4c43-9531-28a3b2ca34ac","topic":"16、17","expanded":true}]}]},{"id":"482ab3238cb9bcf86f293b502b","topic":"哈希/散列表","expanded":true,"children":[{"id":"b2e2c74a-9813-4542-87ff-cf384b83ffb0","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"49086c90-7c3d-4d1d-8356-7353385675a3","topic":"11、14、18、19、22","expanded":true}]},{"id":"19c9aa0d615af6139e74dbc1c5","topic":"哈希表是一种典型的拿空间换时间的数据结构","expanded":true},{"id":"2529af97458a66007d25788816","topic":"概念","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"ab0fea91-5379-443f-91f0-bc31ac4febdb","topic":"散列函数：","expanded":true,"children":[{"id":"72c6c851-1342-4cf4-86f5-e187b6f5e7a1","topic":"H(key)= Hash(key) = Addr","expanded":true}]},{"id":"b42b57d7c239f607fdfb5b50c4","topic":"同义词","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"d9c88ad50dd87a96a6fb394620","topic":"通过一次哈希函数映射到同一地址上的关键词","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"085aa39b6a19a87bb21399c4f9","topic":"H(key1) = H(key2)","expanded":true}]}]},{"id":"2abb4a393e092c3a22e7a97a69","topic":"非同义词","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"ba1a17ed7229d50cb9bd4b45ae","topic":"通过一次哈希函数映射到不同地址上的关键词","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"95a92ce5e509788135b039c188","topic":"H(key1) != H(key2)","expanded":true}]}]},{"id":"769e6fd5-3aff-4ae5-9149-4e36a3386ed2","topic":"冲突","expanded":true,"children":[{"id":"f42d87d0-0917-4815-89e8-4fa6ad3d7748","topic":"同义词引起的，两个或多个同义词关键字想要的地址已经被占用","expanded":true}]},{"id":"eea81cfb80c8446845957825d3","topic":"聚集（堆积）","expanded":true,"children":[{"id":"7feb772ad139ba5130fd5b97b6","topic":"经过Hash后找到了地址，但是还需要【探测】才能找到真正的值","expanded":true,"children":[{"id":"461adf0eec3bc66d7574ea4069","topic":"线性探测：","expanded":true,"children":[{"id":"710ae700828972121bfeaa0c98","topic":"很大情况会聚集","expanded":true}]},{"id":"b4da57c27878b9f123fa2a9644","topic":"再散列、平方、伪随机探测：都可以避免聚集","expanded":true}]}]}]},{"id":"de6b832c286ac25f3dbe38a571","topic":"哈希函数","expanded":true,"children":[{"id":"fbda7e2bf3c8b32945e85b9eb1","topic":"直接定址法","expanded":true,"children":[{"id":"5a3984ebd7eabc5493ab3ac5d0","topic":"H(key) = key 或 H(key) = a * key + b","expanded":true},{"id":"6ec96e10f028cb222f9f4a440a","topic":"不会出现冲突，但是空位多，浪费空间","expanded":true}]},{"id":"d0e9b4fa3909c3cbaa2548c62f","topic":"除留余数法","expanded":true,"children":[{"id":"fb5ae80d198889fd83d629c9f4","topic":"H(key) = key % p","expanded":true},{"id":"5cb8846a59d80757463148c87a","topic":"把p选好，可以减少冲突的概率","expanded":true,"children":[{"id":"ba704f54-1245-4500-89ba-9e1f0e509293","topic":"哈希表的冲突率：由哈希函数的好坏决定","expanded":true}]}]},{"id":"f1b962c6e30ae500b2a088136f","topic":"数字分析法","expanded":true,"children":[{"id":"b3ea92c4086846a6071adbc1ff","topic":"根据出现概率分布情况进行分析得出的方法","expanded":true}]},{"id":"1488ea111e18ff186c4a395d2b","topic":"平方取中法","expanded":true,"children":[{"id":"e9ca82cccbf9325d132f685df9","topic":"取关键字的平方的中间某几位数作为Hash值","expanded":true}]}]},{"id":"920b5c374e184806cbb15af153","topic":"处理冲突","expanded":true,"children":[{"id":"f5fb28da7ff9b6c8b801fb8199","topic":"开放定址法","expanded":true,"children":[{"id":"f7babbf8b7598395c83329750b","topic":"递推式：","expanded":true,"children":[{"id":"4efaf0931e89f284eb4d794086","topic":"Hi = (H(key) +di)%m","expanded":true}]},{"id":"f58aa8718afbd89f2abddad40a","topic":"增量序列di：","expanded":true,"children":[{"id":"17db964496c978e1250b7993ed","topic":"线性探测(再散列)法","expanded":true,"children":[{"id":"78fbec5ea7083eeca77a9ac147","topic":"di = 1, 2, 3 .... m-1","expanded":true}]},{"id":"d5795d76d3fb74f617af993f6e","topic":"平方探测(再散列)法","expanded":true,"children":[{"id":"9c9805eeeb2a81705e49bbdb8a","topic":"di = 0, 1, -1, 4, -4, 9, -9, ..., k^2, -k^2","expanded":true},{"id":"b629f3d007d9bc975aadba54b1","topic":"k一定要 <= m/2 (m为表长)","expanded":true},{"id":"73b8b636e869642fee6f2b6e57","topic":"表长必须是4k+3的素数","expanded":true}]},{"id":"531bdc48558909995256e9421c","topic":"再/双散列法","expanded":true,"children":[{"id":"78b9efee9d7a46b420e3bb2f3a","topic":"Hi = RHash(Hi)","expanded":true,"children":[{"id":"d769a08002cb66f75ac698e073","topic":"使用另一个哈希函数来进行hash值的确定","expanded":true,"children":[{"id":"d7bbf812738b91389ebbd8ef4d","topic":"题目一定会给出另一个Hash函数","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]}]}]},{"id":"a06bc50384388eb27dc7b89f35","topic":"伪随机序列(再散列)法","expanded":true,"children":[{"id":"995b3157ea89038a88df5b3b22","topic":"di = {一个伪随机序列}","expanded":true,"children":[{"id":"d28b8d260b4b1303a2b5795f42","topic":"di是定义好的，所以每次探测的步长是可以知的","expanded":true},{"id":"7e998ab3d16aa63e9eacf9facf","topic":"例如：di = {rand(0, 100), rand(0, 100), rand(0, 100), rand(0, 100)}","expanded":true}]}]}]},{"id":"608bed3b045af53292b16818e6","topic":"问题：","expanded":true,"children":[{"id":"9e79f8cc7a2a6040e7ee0a7f2e","topic":"在开放定址法的哈希表中，删除一个元素是把其标记位Tag改为TRUE","expanded":true,"children":[{"id":"1c1b40f9a5db48c4574cf82150","topic":"不可直接删除，例如线性探测法a[3]，有0, 3, 6，hash结果都为 0，此时如果把a[0] = 0删掉，搜a[1] = 3的时候，搜到a[0]发现没有值，就判断没有","expanded":true}]}]}]},{"id":"1a98b8cbcbdb3c4157a0c90f47","topic":"拉链法","expanded":true,"children":[{"id":"c44912f6c1e908c3797449060d","topic":"遇到冲突了就形成链式结构","expanded":true,"children":[{"id":"820874e7807bd5da9db9e83444","topic":"解决的是同义词的冲突问题","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"22f89b77fd4a8fc672a68b54cf","topic":"删除就可以直接物理删除了","expanded":true}]}]},{"id":"9588bf77aa2bc85b2f0ac93015","topic":"性能分析","expanded":true,"children":[{"id":"74da0b8313c97a1cc6b2a94b68","topic":"ASL","expanded":true,"children":[{"id":"d138d9dd4c780835a015199ea0","topic":"成功失败分别计算即可（算法就是模拟插入过程，手算，求和平均）","expanded":true}]},{"id":"6f787762a83b5df88c905aba6f","topic":"装填因子","expanded":true,"children":[{"id":"12fac93bc5bacf943ed80bb767","topic":"","expanded":true,"children":[{"id":"713948bf05498b38dcdc693933","topic":"装填因子越大，表示装的越满，冲突的可能更大","expanded":true},{"id":"05193886dc283df682ee9b9ea8","topic":"越小表示发生冲突的可能性更小","expanded":true}],"formula":{"tex":"\\alpha = \\frac{\\text{表中记录数 } n}{\\text{散列表长度 } m}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>α</mi><mo>=</mo><mfrac><mrow><mtext>表中记录数 </mtext><mi>n</mi></mrow><mrow><mtext>散列表长度 </mtext><mi>m</mi></mrow></mfrac></mrow><annotation encoding=\"application/x-tex\">\\alpha = \\frac{\\text{表中记录数 } n}{\\text{散列表长度 } m}</annotation></semantics></math></span>"}}]},{"id":"a83926877b291301c2a44952e8","topic":"会受到冲突影响的是：","expanded":true,"children":[{"id":"70a96cdc004a8c59f9988ba419","topic":"ASL","expanded":true,"children":[{"id":"994a70b9587aa53133e608a06a","topic":"✅","expanded":true}]},{"id":"072b3e7fbc6bdaf99f663921e6","topic":"装填因子","expanded":true,"children":[{"id":"33681c11e4eb4f0ecf3868f6c7","topic":"❎","expanded":true,"children":[{"id":"581bb66faae84f2f803c5b8239","topic":"n、m和冲突都没有关系，反而是装填因子可以影响冲突的概率","expanded":true}]}]}]}]},{"id":"ecd3c9b1-0be6-4fda-a1e2-3eec4f6f701c","topic":"冲突的探讨","expanded":true,"children":[{"id":"8b3bfcb1-6d44-4a69-8b1b-7ffafd79f342","topic":"非同义词会不会引起冲突？","expanded":true,"style":{"background":"#FF9595"}},{"id":"31d20dcb-3085-44fd-baab-4e23d200f4d1","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-12bf9f0a703ccb.png","width":187,"height":140},"children":[{"id":"1e0801b2-1de8-4315-b57d-fbf91e06b2be","topic":"252页","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-6068295f297be4.png","width":377,"height":62}},{"id":"d332c3e5-a619-4b27-bfa5-921d46c6d66a","topic":"257页（但是在讲散列探测方法之前）","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d4ea42e5f4028f.png","width":379,"height":40}}]}]}]},{"id":"b77b522cfed82b833991a8d14b","topic":"END","expanded":true}]},"relations":[{"id":"ea6bcacd5ecba742e85f599ce7","from":"0dda385e793b332185b5f9540a","to":"a99b2081b238e97f591bb821e3","bidirectional":false}],"summaries":[{"id":"379e5195-b2a8-4c3f-a309-9693cffc4245","parentId":"262229e3-c0f9-44d8-a85b-5ea6435f53d4","start":0,"end":1,"label":""},{"id":"5b735952-bc03-4c13-bfc7-0d8cdd642d8e","parentId":"7cfd76bc-f66f-4f88-8030-81c9c6193678","start":0,"end":0,"label":"最好说是可能超过2次（因为 <= 3不严格正确，参考“左倾红黑树”）"},{"id":"322bcab2be09ecf9725f0882c1","parentId":"c11af5ab122aff80c4bdf9ad07","start":3,"end":3,"label":"B树"},{"id":"e5286bb759ebda86b0a9e8d567","parentId":"d0e9b4fa3909c3cbaa2548c62f","start":0,"end":0,"label":"一般p是取一个最接近表长的素数"}],"boundaries":[{"id":"973ba3a4acbbea52fb625b2200","parentId":"5589e2b5bca8ca497f5d9b0ca9","start":0,"end":0,"label":"巧记"},{"id":"a50bae80470a5418838f6a10cf","parentId":"2529af97458a66007d25788816","start":4,"end":4,"label":"是针对【开放定址法】的概念"},{"id":"236910f42a7b5145a8e0e987ea","parentId":"1a98b8cbcbdb3c4157a0c90f47","start":0,"end":0,"label":"直接解决了堆积的问题，不会出现堆积"}]}