{"format":"brushup-mindmap-v1","id":"ds-00-sheet0","title":"数据结构","structure":"mindmap","theme":"auto","root":{"id":"b9aa22deba98b3b20c7ac8aca2","topic":"数据结构","expanded":true,"children":[{"id":"b58888b5ceebbf0e68dada0656","topic":"第一章：绪论","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/data-structures/ds-00-sheet1","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"ds-00-sheet1","title":"第一章：绪论","structure":"timeline-h","theme":"auto","root":{"id":"6b4b820f6fbaa59d929a8a4588","topic":"第一章：绪论","expanded":true,"children":[{"id":"53fae278d8caa4881050eae0f6","topic":"概念","expanded":true,"children":[{"id":"7ccbcfbfedc89651f647998b36","topic":"数据分类","expanded":true,"children":[{"id":"b6598287b748f50ca1aef8271f","topic":"数据结构","expanded":true,"children":[{"id":"cf7bd501f529478f82c64b9de3","topic":"关系","expanded":true,"children":[{"id":"ab1859b0f119b0651a0b2b5bab","topic":"存在一种或多种特定关系的数据元素的集合","expanded":true}]}]},{"id":"38c84adab62bf79f608fa956f9","topic":"数据对象","expanded":true,"children":[{"id":"30bb71dd190b47e86704ca6c6a","topic":"相同性质","expanded":true,"children":[{"id":"436ad7702b282683d443ab582c","topic":"具有相同性质的数据元素的集合","expanded":true}]}]},{"id":"d898c645435ad829faf6e8c9e9","topic":"数据元素","expanded":true},{"id":"34398992891832b56595a9ddb9","topic":"数据项","expanded":true},{"id":"3cbb3cc9a4393f472358fa1ccd","topic":"图片","expanded":true,"children":[{"id":"fb1bb282bd496b0e5db51bc3e5","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-aa543b4fab9652.png","width":467,"height":342}}]}]},{"id":"e5887a28f2891dfe9c51d8e843","topic":"数据类型","expanded":true,"children":[{"id":"162bdd17b5e9775d43e23aab1d","topic":"数据类型","expanded":true,"children":[{"id":"d8b8eca94dd920a87e39095944","topic":"概念","expanded":true,"children":[{"id":"7d680ae1489a39c157d83aecc8","topic":"一个值的集合","expanded":true},{"id":"5e89bea8609b0ee945d64a126d","topic":"在这个集合上可以进行的操作","expanded":true}]},{"id":"08c8251e896befb968180ba521","topic":"分类","expanded":true,"children":[{"id":"5e0acf768df87181c2fda9547f","topic":"原子类型","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"3539da6f4d59f16a32db081cd6","topic":"不可再分","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"a6aa72069b18fec97188ebb457","topic":"结构类型","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"89ab507c946bf6f1f1760a501e","topic":"可以再分","expanded":true,"style":{"background":"#FDD834"}}]}]}]},{"id":"4248ee4bded82512688c584aaa","topic":"抽象数据类型（ADT）","expanded":true,"children":[{"id":"047b984d3bea93bd55cd3ba220","topic":"抽象的数据组织与之相关的操作","expanded":true},{"id":"2a9b88000e48afd3f11b4bc7c1","topic":"数据","expanded":true,"children":[{"id":"8ddbab971b18bb7e9bee6b3810","topic":"数据对象","expanded":true,"children":[{"id":"6a4bf1f43f3bec3962573a1be1","topic":"数据类型就已经隐含在了数据对象里面了，例如定义的时候的 int a，或者ElemType e","expanded":true}]},{"id":"2bb86883a0e82e338205b99e88","topic":"数据关系","expanded":true,"children":[{"id":"006bc9b0000b9070351eea34d6","topic":"【数据对象的集合结构】，例如一对一（线性表），一对多（树）","expanded":true}]}]},{"id":"7aaa92ee6d98e244d0a70a0a1a","topic":"基本操作集","expanded":true,"children":[{"id":"f86a5996dd4a03da66c3187835","topic":"就是数据的存取方法","expanded":true}]}]}]},{"id":"da324b72-6152-4b39-8f81-4657204a2a0b","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"680b0eb5448bfac73ecf4912bf","topic":"数据结构三要素","expanded":true,"children":[{"id":"0bcc0c17-220d-47a0-95e7-4897afd83e26","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"407a6b59a7fa885af35d0a652a","topic":"逻辑结构","expanded":true,"icons":["priority:1"],"children":[{"id":"d8d8689ecb1afcf5a5f4d8addf","topic":"集合结构","expanded":true,"children":[{"id":"fd0bbe99bb691c550f1479e8dd","topic":"和数学里的集合概念一致","expanded":true}]},{"id":"3b3a00e5f73921f10fa898a219","topic":"线性结构","expanded":true,"children":[{"id":"2eb931f24f4b0e59e6a45a4ef3","topic":"特点：","expanded":true,"children":[{"id":"7f8b7ec7151bf9a1a77468f70b","topic":"每个元素都是一对一的关系，除了第一个元素都由前驱，除了最后一个元素都有后继","expanded":true}]}]},{"id":"3749e3db283b06c76ab21bf422","topic":"树形结构","expanded":true,"children":[{"id":"bcb896e1a18a4667d8c61b1d7c","topic":"一对多","expanded":true},{"id":"d38a862278f9d2c04c7e5ab349","topic":"OS中的目录结构就是树形结构","expanded":true}]},{"id":"46fbc2cf583820939d71e97bef","topic":"图结构","expanded":true,"children":[{"id":"a16a59367088b387f7ad0b07ff","topic":"多对多","expanded":true}]},{"id":"938ad5a3df098cbc24b749ea06","topic":"或者王道上的分类方式：","expanded":true,"children":[{"id":"1a697184008964371085dad47b","topic":"线性结构","expanded":true,"children":[{"id":"8438f28f540aa750eee5ebeb14","topic":"一般线性表","expanded":true},{"id":"84cb8d41742a09d6160159239e","topic":"受限线性表","expanded":true,"children":[{"id":"89bb1c5b8efb6d8ad2a63b66c2","topic":"栈和队列","expanded":true},{"id":"c48bcc737198a905be7898db55","topic":"串","expanded":true}]},{"id":"f33acbb8d46925904ff9aabde3","topic":"线性表的推广","expanded":true,"children":[{"id":"0fb958bc02188c662365ab5ccb","topic":"数组","expanded":true}]}]},{"id":"042ba9561ff91cde9523bb5901","topic":"非线性结构","expanded":true,"children":[{"id":"5bbb76ef66daaa5ccb7d5b1a6f","topic":"集合","expanded":true},{"id":"f21a0447132b07dff95d7a2814","topic":"树","expanded":true,"children":[{"id":"c478caa0744886d640567abfd2","topic":"一般树","expanded":true},{"id":"24f88b77d19be171e894c908cb","topic":"二叉树","expanded":true}]},{"id":"506abb8c562b37bc1fe44972ab","topic":"图","expanded":true,"children":[{"id":"a68869085d8a76a95ee74bb31b","topic":"有向图","expanded":true},{"id":"d16950e78b2981a7d7d7697b25","topic":"无向图","expanded":true}]}]}]}]},{"id":"d2ab65467ba881b38ba6a9916b","topic":"数据的运算","expanded":true,"icons":["priority:2"]},{"id":"0eeba669508a8093bf151a63e4","topic":"物理结构\n【类比OS中的\n文件物理结构\n来理解】","expanded":true,"icons":["priority:3"],"children":[{"id":"f41842e260b92ec99bfceb67ec","topic":"线性存储","expanded":true,"children":[{"id":"155b5d932bbb0f4c8d3eaa35b6","topic":"（OS文件：循序存储），在物理上相邻的存放","expanded":true}]},{"id":"62785000995ac309ff4aaa17ea","topic":"链式存储","expanded":true,"children":[{"id":"bdfae73596b9261c59fd6bdd6f","topic":"链表，离散存储，每个物理内容中含有指向下一个的指针","expanded":true}]},{"id":"c8bb1f3dc36a0d2366962971d1","topic":"索引存储","expanded":true,"children":[{"id":"b28923eac4baf08838251a0f1a","topic":"用索引表来存地址","expanded":true,"children":[{"id":"aaa9cc74af9966354f765b35fa","topic":"通过索引表的索引信息来查","expanded":true}]}]},{"id":"5d5a4e9a967ab8094b5489394c","topic":"散列存储","expanded":true,"children":[{"id":"8ffa7b8a94bb257a82e82b57be","topic":"哈希","expanded":true}]}]},{"id":"1a3ad24c8c08d5b9762c2927cc","topic":"关系：","expanded":true,"children":[{"id":"ea899a5dfba8b64cd8204b07ae","topic":"逻辑结构是设计者独立思考后采用的抽象表示方式，独立于存储结构","expanded":true},{"id":"7589615b0eb8050f2013e80933","topic":"存储结构是逻辑结构在计算机上的映射，它不能独立于逻辑结构而存在","expanded":true,"children":[{"id":"59fa47991b38b46c312498d414","topic":"例如int[]就是连续空间，ListNode就是离散空间","expanded":true}]},{"id":"1e15adfa-b3a9-47dd-916f-40b0afe53dd2","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-380e8546425b83.png","width":665.18,"height":441.62}}]}]},{"id":"ee5b9cf71ff9129fe3e9c8f817","topic":"算法","expanded":true,"children":[{"id":"7179b6f786d9bc63426fd95985","topic":"概率","expanded":true,"children":[{"id":"c958b5c72bebe34501a088da5b","topic":"对特定问题求解步骤的描述","expanded":true}]},{"id":"1b79fc401a9a41acbfed892ce7","topic":"特性","expanded":true,"children":[{"id":"29ab557e9ef8e43ff2ee3a54a5","topic":"有穷性（时间、步骤）","expanded":true},{"id":"fb180fc38fab998ccc84885da3","topic":"确定性","expanded":true},{"id":"4d98f96a4d69b77d513258654e","topic":"可行性","expanded":true},{"id":"bab96e3e02e8e24a91e1ea6167","topic":"输入","expanded":true},{"id":"224848cfbad9b15748311bfb81","topic":"输出","expanded":true}]},{"id":"297a94703d7844090070f9d8b1","topic":"好算法的特质","expanded":true,"children":[{"id":"b98b6813ee598fa33323896922","topic":"正确性","expanded":true},{"id":"9bb82538f69a05eeaf997a2327","topic":"可读性","expanded":true},{"id":"b46a58baa1eb4ec8a8547ab9ed","topic":"健壮性","expanded":true,"children":[{"id":"fa38620c540b068f49ccd8df99","topic":"非法数据的处理","expanded":true}]},{"id":"6169ebddde1954c5010de821fa","topic":"时间复杂度低","expanded":true},{"id":"f4b8fb4b672a1e0d985a292584","topic":"空间复杂度低","expanded":true}]},{"id":"59243d17-c79a-4f45-9b81-38dc0c9b9b5f","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"cc0adecc289b064bd19079fcab","topic":"算法复杂度","expanded":true,"children":[{"id":"4e98f897-c0e8-4fc0-9222-4a998231693d","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"45ae801e-83fa-4f6a-9422-1e26b7a5bfe4","topic":"11、12、13、14、17、19、22","expanded":true}]},{"id":"acfb1b29eef923af4419295025","topic":"时间复杂度","expanded":true,"children":[{"id":"0bca25db-e54a-43ae-b52b-d2346104621c","topic":"计算：","expanded":true,"children":[{"id":"3051f422-b36f-4f98-8931-664699f2a05c","topic":"1. 找到基本操作（最深层的循环）","expanded":true},{"id":"3d65c2bc-5847-41ce-852c-e41919d4391f","topic":"2. 分析该基本操作的执行次数 x 和问题的规模 n 的数学形式关系","expanded":true,"formula":{"tex":"x = f(n)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>x</mi><mo>=</mo><mi>f</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">x = f(n)</annotation></semantics></math></span>"}},{"id":"39e2092c-9645-45f0-878a-024bba675ab4","topic":"3. x 的数量级 O(x) 是算法时间复杂度 T(n)","expanded":true}]},{"id":"d0922e0a-f763-48eb-ac43-5d836d0261a5","topic":"常用技巧：","expanded":true,"children":[{"id":"cf811bfd-2ddc-40a2-a93b-28daad3c075a","topic":"加法规则","expanded":true,"formula":{"tex":"O(f(n)) + O(g(n)) = O(\\max(f(n), g(n)))","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><mi>f</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">)</mo><mo>+</mo><mi>O</mi><mo stretchy=\"false\">(</mo><mi>g</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">)</mo><mo>=</mo><mi>O</mi><mo stretchy=\"false\">(</mo><mi>max</mi><mo>⁡</mo><mo stretchy=\"false\">(</mo><mi>f</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo separator=\"true\">,</mo><mi>g</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(f(n)) + O(g(n)) = O(\\max(f(n), g(n)))</annotation></semantics></math></span>"}},{"id":"ea48366d-81cc-45fd-9737-f26edffa97e7","topic":"乘法规则","expanded":true,"formula":{"tex":"O(f(n)) \\times O(g(n)) = O(f(n) \\times g(n))","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><mi>f</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">)</mo><mo>×</mo><mi>O</mi><mo stretchy=\"false\">(</mo><mi>g</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">)</mo><mo>=</mo><mi>O</mi><mo stretchy=\"false\">(</mo><mi>f</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo>×</mo><mi>g</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(f(n)) \\times O(g(n)) = O(f(n) \\times g(n))</annotation></semantics></math></span>"}},{"id":"5a2510db-b644-4bc1-96ec-2094647aea50","topic":"咸鱼口诀：“常对幂指阶”","expanded":true,"style":{"background":"#FF9595"},"formula":{"tex":"\\begin{aligned} &O(1) < O(\\log_2 n) < O(n) < O(n\\log_2 n) < O(n^2) \\\\ &< O(n^3) < O(2^n) > O(n!) < O(n^n) \\end{aligned}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mtable rowspacing=\"0.25em\" columnalign=\"right left\" columnspacing=\"0em\"><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow><mrow></mrow><mi>O</mi><mo stretchy=\"false\">(</mo><mn>1</mn><mo stretchy=\"false\">)</mo><mo>&lt;</mo><mi>O</mi><mo stretchy=\"false\">(</mo><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mi>n</mi><mo stretchy=\"false\">)</mo><mo>&lt;</mo><mi>O</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo>&lt;</mo><mi>O</mi><mo stretchy=\"false\">(</mo><mi>n</mi><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mi>n</mi><mo stretchy=\"false\">)</mo><mo>&lt;</mo><mi>O</mi><mo stretchy=\"false\">(</mo><msup><mi>n</mi><mn>2</mn></msup><mo stretchy=\"false\">)</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow><mrow></mrow><mo>&lt;</mo><mi>O</mi><mo stretchy=\"false\">(</mo><msup><mi>n</mi><mn>3</mn></msup><mo stretchy=\"false\">)</mo><mo>&lt;</mo><mi>O</mi><mo stretchy=\"false\">(</mo><msup><mn>2</mn><mi>n</mi></msup><mo stretchy=\"false\">)</mo><mo>&gt;</mo><mi>O</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">!</mo><mo stretchy=\"false\">)</mo><mo>&lt;</mo><mi>O</mi><mo stretchy=\"false\">(</mo><msup><mi>n</mi><mi>n</mi></msup><mo stretchy=\"false\">)</mo></mrow></mstyle></mtd></mtr></mtable><annotation encoding=\"application/x-tex\">\\begin{aligned} &amp;O(1) &lt; O(\\log_2 n) &lt; O(n) &lt; O(n\\log_2 n) &lt; O(n^2) \\\\ &amp;&lt; O(n^3) &lt; O(2^n) &gt; O(n!) &lt; O(n^n) \\end{aligned}</annotation></semantics></math></span>"}}]},{"id":"6b27d330-8ac6-4229-80ef-c30fccd2bb77","topic":"三种复杂度：","expanded":true,"children":[{"id":"f62c5913-1886-4f13-b8bb-7a076592ba12","topic":"最坏时间复杂度：考虑输入数据“最坏”的情况","expanded":true},{"id":"475556e8-5883-4f7a-86c7-aa78cbe616b3","topic":"平均时间复杂度：考虑所有输入数据等概率出现的情况","expanded":true},{"id":"c3b8bfbf-15fa-45cd-a392-304c8a9344e3","topic":"最好时间复杂度：考虑输入数据“最好”的情况","expanded":true}]}]},{"id":"9e291cf7af3a97d9168b7be5dc","topic":"空间复杂度","expanded":true,"children":[{"id":"658ab8ce-1ae2-4441-b60a-49ecda38d9a3","topic":"如何计算","expanded":true,"children":[{"id":"c276d5cf-e155-4e24-a4f5-ad3302bd7515","topic":"1. 算法空间大小和问题规模的关系","expanded":true},{"id":"d007c000-1fc0-4e61-bd71-f243a5865f75","topic":"2. 数学形式分析：空间x，问题规模n","expanded":true,"formula":{"tex":"x = f(n)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>x</mi><mo>=</mo><mi>f</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">x = f(n)</annotation></semantics></math></span>"}},{"id":"5e89e448-d40a-4fd8-8133-8bcfbdaacfc0","topic":"3. x 的数量级 O(x) 就是算法的空间复杂度S(n)","expanded":true},{"id":"2b8f8a19-996c-4f4f-a59e-a279216bdb2b","topic":"注：如果是递归程序，则各层算法所需存储空间不同，分析方法有所区别","expanded":true}]},{"id":"c3335ae5-2b38-444a-b669-86afb99412df","topic":"常用技巧：","expanded":true,"children":[{"id":"862c45e0-01ca-4eb0-8988-d3d29785e81b","topic":"同上 ↑","expanded":true}]},{"id":"1738b4cc7009c29da2a2283e3f","topic":"原地工作","expanded":true,"children":[{"id":"81fa7ba1765ab16dd5de5ae1e4","topic":"空间复杂度O(1)","expanded":true,"children":[{"id":"1db747d6-da3d-44c6-ad48-363b092e31fa","topic":"程序消耗的空间和问题规模没有相关性","expanded":true,"style":{"background":"#FDD834"}}]}]}]}]},{"id":"148af1d15ddbee555741e8c2aa","topic":"存取存储器","expanded":true,"children":[{"id":"82f9982fbd7a59f9a60418bcda","topic":"RAM随机存取存储器","expanded":true,"children":[{"id":"e20bf781e00be42972a1089216","topic":"可以直接访问任一个存储单元，只要知道该单元所在记忆行和记忆列的地址即可。","expanded":true},{"id":"dad8b6cbb7483d281f9feb793f","topic":"分为三个部分","expanded":true,"children":[{"id":"165b750d4a5a080feec988c914","topic":"存储矩阵","expanded":true},{"id":"ff491eef33086bf5a4827a95c7","topic":"地址译码器","expanded":true},{"id":"5a48c403774a05d27e02596a71","topic":"读写电路","expanded":true}]}]},{"id":"e66b0c15792ab443d2132b5801","topic":"SAM顺序存取存储器","expanded":true,"children":[{"id":"c36a5003ea5bba29ab27bafa7e","topic":"SAM中的数据存储单元按照线性顺序排列，因而只能依顺序访问（类似于盒式录音带）。如果当前位置不能找到所需数据，就必须依次查找下一个存储单元，直至找到所需数据为止。SAM非常适合作缓冲存储器之用，一般情况下，缓存中数据的存储","expanded":true}]},{"id":"3cf6b7c8-e37b-47cb-86f3-71b3ef9a876b","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"7569cdec-067b-4013-a8dc-69a6a11a45c5","topic":"END","expanded":true}]},"summaries":[{"id":"1bda4b6aa428da609a3719fa08","parentId":"0eeba669508a8093bf151a63e4","start":1,"end":3,"label":"非线性存储"}],"boundaries":[{"id":"cba9a73d-68d1-469f-b45f-8c42a768b3b9","parentId":"e5887a28f2891dfe9c51d8e843","start":1,"end":1,"label":"一个完整的ADT可以定义一个数据结构"},{"id":"4baa7619a84ad368b39d38ccf6","parentId":"407a6b59a7fa885af35d0a652a","start":0,"end":0,"label":"22年考纲新增"}]}}},{"id":"193b56735e689ae86a01d91513","topic":"第二/三章：线性表/栈/队列","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/data-structures/ds-00-sheet2","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"ds-00-sheet2","title":"第二/三章：线性表/栈/队列","structure":"timeline-h","theme":"auto","root":{"id":"801af10a982b5852a704e8a351","topic":"第二/三章：线性表/栈/队列","expanded":false,"children":[{"id":"5c8831735a6820106a71893d07","topic":"线性表定义","expanded":true,"children":[{"id":"0b7945be0449a0a07e748904aa","topic":"要求：","expanded":true,"children":[{"id":"3b4a95957c5942d7c5f97aea43","topic":"相同数据类型的n个数据元素","expanded":true},{"id":"6a28fa3cbc3a9284f7e1da34ce","topic":"逻辑上的有限序列","expanded":true}]},{"id":"ba7936150eea1cde4cf8a8d90b","topic":"相同数据类型的n个数据元素的有限序列","expanded":true,"children":[{"id":"b4781a5151f896e43c0589153c","topic":"n=0叫空表","expanded":true}]},{"id":"deba2c48ff49ef98a1b55912f8","topic":"位序、表头元素、表尾元素","expanded":true},{"id":"f7ba4c50a9d8cb3e0f7d0913e8","topic":"前驱、后继","expanded":true},{"id":"f07958bd30aa20f16d712a2304","topic":"基本操作","expanded":true,"children":[{"id":"df28cb38142a87ffcc490b8438","topic":"初始化","expanded":true},{"id":"94fb12264918f1c772c98aa7e0","topic":"销毁","expanded":true},{"id":"027941b0b848829f46373839ce","topic":"插入","expanded":true},{"id":"faaa38c2500b03244699292d12","topic":"删除","expanded":true},{"id":"268a5ed5abda4cfff61dbb725a","topic":"按值查找","expanded":true},{"id":"d0583c4660a9333798831b5a5f","topic":"按位查找","expanded":true},{"id":"4e899588510880664fe1fbf029","topic":"其他操作","expanded":true,"children":[{"id":"034a1f45ce6af624e454097e50","topic":"求表长","expanded":true},{"id":"e30a286b535928882246b9e896","topic":"输出表","expanded":true},{"id":"985a8405c8ba51c5d1b1c870b4","topic":"判空","expanded":true}]}]},{"id":"34fe2b2e-d5be-4981-8622-65225f6ddaaf","topic":"逻辑结构","expanded":true},{"id":"c6edaa52-f2b0-45b2-82e0-3033034fe64a","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"53ea799e4bfa45b0da42caaae6","topic":"顺序表","expanded":true,"children":[{"id":"6ab15c96-0cf2-461d-82a5-d3d5ec04093f","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"3ea1e6d1-2981-477f-889b-6c685543a117","topic":"10大、11大、13大、18大、20大","expanded":true}]},{"id":"9198ca1ae398630217e4f8d8ca","topic":"定义","expanded":true,"children":[{"id":"e37869c053eb40b0a2ef5a75ce","topic":"顺序存储的线性表","expanded":true,"children":[{"id":"81e66218-fe2d-4dde-b1b0-853f14ee7483","topic":"逻辑结构+物理结构","expanded":true}]}]},{"id":"f45a68550c3a2fbd64b6d8d30b","topic":"特点","expanded":true,"children":[{"id":"48cb9abefee812cf1bf1da70b7","topic":"随机访问","expanded":true,"children":[{"id":"abf9bfd3c3ebc858ae1d285d5d","topic":"查找数组O(1)","expanded":true}]},{"id":"357a05708daa54e9b8fc3ac58a","topic":"存储密度高","expanded":true,"children":[{"id":"780bfbe97c990de6eb972b6758","topic":"相比较链表","expanded":true}]},{"id":"10cb46dd60ca1598b11178cb79","topic":"拓展容量不方便","expanded":true,"children":[{"id":"068aae4e-f9ed-45fa-b9c5-80f2d7d8308b","topic":"重新开辟新空间进行拷贝","expanded":true}]}]},{"id":"1c59540bd54b78482108a8f649","topic":"创建","expanded":true,"children":[{"id":"7489498d4fbaed1215d74a2278","topic":"静态分配","expanded":true,"children":[{"id":"aa987a4b97d86b21a11898e394","topic":"data[MaxSize]","expanded":true}]},{"id":"c3795e20912bb6ee5e372bfd4d","topic":"动态分配","expanded":true,"children":[{"id":"deab23fa137bb34e91be699aff","topic":"*data = malloc(sizeof(ElemType) * length)","expanded":true},{"id":"c04ae356796ba7d4b41f08cd27","topic":"释放：free(data)","expanded":true},{"id":"d94b1e18cc4bf0eccf3beb22e8","topic":"增加动态数组的长度","expanded":true,"children":[{"id":"735b46fdc64a27ef6204ca527d","topic":"IncreaseSize","expanded":true,"code":{"lang":"cpp","code":"//增加动态数组的长度\nvoid IncreaseSize(SeqList &L, int len) {\n    int *p = L.data;\n    L.data = (int *) malloc((L.MaxSize + len) * sizeof(int));\n    for (int i = 0; i < L.length; i++) {\n        L.data[i] = p[i];           //将数据复制到新区域\n    }\n    L.MaxSize = L.MaxSize + len;    //顺序表最大长度增加 len\n    free(p);                        //释放原来的内存空间\n}","title":"IncreaseSize","tokens":[[{"text":"//增加动态数组的长度","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"IncreaseSize","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"SeqList","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"&","darkColor":"#8EA4E2"},{"text":"L","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"*","darkColor":"#8EA4E2"},{"text":"p","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#D5C5AA"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#D5C5AA"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"*)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"malloc","darkColor":"#6EC0DF"},{"text":"((","darkColor":"#BAB5A8"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"MaxSize","darkColor":"#D5C5AA"},{"text":" ","darkColor":"#DEDBD2"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"*","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"sizeof(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":"));","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#D5C5AA"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":"++)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#D5C5AA"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"p","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":"           //将数据复制到新区域","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"MaxSize","darkColor":"#D5C5AA"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"MaxSize","darkColor":"#D5C5AA"},{"text":" ","darkColor":"#DEDBD2"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":"    //顺序表最大长度增加 len","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"free","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"p","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":"                        //释放原来的内存空间","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}]}]},{"id":"ffc91e3496cb355b7668d97b90","topic":"插入","expanded":true,"children":[{"id":"aefa04c59e7844825253493a90","topic":"代码：注意代码的健壮性","expanded":true,"children":[{"id":"6c292fd69daa7732d71b6b2cb2","topic":"ListInsert","expanded":true,"code":{"lang":"cpp","code":"bool ListInsert(SqList &L, int i, int e) {\n    if (i < 1 || i > L.length + 1)   //判断i的范围是否有效\n        return false;\n    if (L.length >= MaxSize)         //当前存储空间已满，不能插入\n        return false;\n    for (int j = L.length; j >= i; j--) //将第i个元素及之后的元素后移\n        L.data[j] = L.data[j - 1];\n    L.data[i - 1] = e;               //在位置i处放入e\n    L.length++;                      //长度加1\n    return true;\n}","title":"ListInsert","tokens":[[{"text":"bool","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"ListInsert","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"SqList","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"&","darkColor":"#8EA4E2"},{"text":"L","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"e","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":" ","darkColor":"#DEDBD2"},{"text":"||","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#D5C5AA"},{"text":" ","darkColor":"#DEDBD2"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":"   //判断i的范围是否有效","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"false","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#D5C5AA"},{"text":" ","darkColor":"#DEDBD2"},{"text":">=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"MaxSize","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":"         //当前存储空间已满，不能插入","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"false","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#D5C5AA"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":"--)","darkColor":"#BAB5A8"},{"text":" //将第i个元素及之后的元素后移","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#D5C5AA"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#D5C5AA"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#D5C5AA"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"e","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":"               //在位置i处放入e","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#D5C5AA"},{"text":"++;","darkColor":"#BAB5A8"},{"text":"                      //长度加1","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"true","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"9f988839fc7b9f24325c0a1212","topic":"时间复杂度","expanded":true,"children":[{"id":"bbe8e95924789361006448e411","topic":"最好","expanded":true,"children":[{"id":"402b236285da1f9ac56c086ddc","topic":"O(1)","expanded":true}]},{"id":"5118dc8df2cb7e88b8196ace3d","topic":"最坏","expanded":true,"children":[{"id":"29ea868a220991cdf708490667","topic":"O(n)","expanded":true}]},{"id":"58096f70e52a899cdc96e93c8e","topic":"平均","expanded":true,"children":[{"id":"eabbc9e6267bdb4f4bafe8fafb","topic":"O(n/2) = O(n)","expanded":true}]}]}]},{"id":"5d6adf312ecbc5e17958aa7a32","topic":"删除","expanded":true,"children":[{"id":"4928b539d61978200cad1ab615","topic":"代码","expanded":true,"children":[{"id":"de2a6f9f2c09707ec5d308f00a","topic":"ListDelete","expanded":true,"code":{"lang":"cpp","code":"bool ListDelete(SqList &L, int i, int &e) {\n    if (i < 1 || i > L.length)       //判断i的范围是否有效\n        return false;\n    e = L.data[i - 1];               //将被删除的元素赋值给e\n    for (int j = i; j < L.length; j++) //将第i个位置后的元素前移\n        L.data[j - 1] = L.data[j];\n    L.length--;                      //长度减1\n    return true;\n}","title":"ListDelete","tokens":[[{"text":"bool","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"ListDelete","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"SqList","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"&","darkColor":"#8EA4E2"},{"text":"L","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"&","darkColor":"#8EA4E2"},{"text":"e","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":" ","darkColor":"#DEDBD2"},{"text":"||","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":"       //判断i的范围是否有效","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"false","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"e","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#D5C5AA"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":"];","darkColor":"#BAB5A8"},{"text":"               //将被删除的元素赋值给e","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#D5C5AA"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":"++)","darkColor":"#BAB5A8"},{"text":" //将第i个位置后的元素前移","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#D5C5AA"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#D5C5AA"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#D5C5AA"},{"text":"--;","darkColor":"#BAB5A8"},{"text":"                      //长度减1","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"true","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"c22aad58afbb41dd1e4358f436","topic":"时间复杂度","expanded":true,"children":[{"id":"9e98f9bf49ca0717b726aa7073","topic":"最好","expanded":true,"children":[{"id":"cf5a72df761946c29b0f0aed36","topic":"O(1)","expanded":true}]},{"id":"3aa983671f9aabc503bb9a7815","topic":"最坏","expanded":true,"children":[{"id":"780aae6395fb43b15b8b7a5ba1","topic":"O(n)","expanded":true}]},{"id":"c62932f2768911ab184ffad478","topic":"平均","expanded":true,"children":[{"id":"9188c126970803e1e6b6ca61bd","topic":"O(n/2) = O(n)","expanded":true}]}]}]},{"id":"57ca52dc373a9b17e8c0e94d00","topic":"查找","expanded":true,"children":[{"id":"9bd8914f-184a-4d80-a34a-14479b798c5d","topic":"代码：","expanded":true,"children":[{"id":"a5e84ca5-e050-47a3-84b2-a126cde45ebc","topic":"LocateElem","expanded":true,"code":{"lang":"c","code":"int LocateElem(SqList L, ElemType e) {\n    int i;\n    for(i = 0; i < L.length; i++)\n        if(L.data[i] == e)\n            return i + 1; // 下标为i的元素值=e，说明是第(i+1)个\n\n    return 0;\n}","title":"LocateElem","tokens":[[{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"LocateElem","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"SqList ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ElemType ","darkColor":"#DEDBD2"},{"text":"e","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" i","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"i ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" i ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" i","darkColor":"#DEDBD2"},{"text":"++)","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"data","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" e","darkColor":"#DEDBD2"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" i ","darkColor":"#DEDBD2"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 下标为i的元素值=e，说明是第(i+1)个","darkColor":"#908B7E"}],[{"text":" "}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"73593404b7eafcdc510e7ad09e","topic":"按位查找","expanded":true,"children":[{"id":"b8e9389e79b8af3447d19b2f77","topic":"获得表L中的第i个位置的元素的值","expanded":true},{"id":"0268eef0d1d8fef36a7929e709","topic":"时间复杂度","expanded":true,"children":[{"id":"93b8702211ebf88193a47b5363","topic":"O(1)","expanded":true}]}]},{"id":"e7192e590e2a03eefe1b29edf7","topic":"按值查找","expanded":true,"children":[{"id":"23f9b4a1c4382ba1c82c2bad59","topic":"搜索即可","expanded":true},{"id":"f58b2000f1886e7a7e64ebe5fb","topic":"时间复杂度","expanded":true,"children":[{"id":"3b4851aa298a4443bbc00bebb1","topic":"O(n)","expanded":true}]}]}]}]},{"id":"7ba836f99089c9394a67c85962","topic":"链表","expanded":true,"children":[{"id":"d1097a43414b58b659596b863b","topic":"单链表","expanded":true,"children":[{"id":"6e3ac68d-7346-40d8-ace9-6fcc2877e3d3","topic":"定义","expanded":true,"children":[{"id":"1a2962f2-5ea9-49ff-b501-22ffb6117ae2","topic":"线性表的链式存储","expanded":true,"children":[{"id":"14b0887f-283f-4edb-879e-c89dade160bb","topic":"逻辑+物理","expanded":true}]}]},{"id":"f29b6b54feea360c0d73d9d1a0","topic":"链表类型","expanded":true,"children":[{"id":"e9c8ad4a19bb4e622c8b094812","topic":"带头节点","expanded":true,"children":[{"id":"c3d8349b9919b0c28aeb78fed7","topic":"头节点即第0个元素","expanded":true}]},{"id":"3d5af955a75a25539097da61bd","topic":"不带头节点","expanded":true,"children":[{"id":"9c4b74ae8589144faf5539fe18","topic":"元素从第一个开始","expanded":true}]}]},{"id":"6ec9a3ccf52b73cb3544199ea8","topic":"优缺点","expanded":true,"children":[{"id":"4d390484958a42313ae18863fc","topic":"优点：不要求大片存储空间","expanded":true},{"id":"a2f89b3dd819e9970b6ebbcd90","topic":"缺点：不支持随机存取","expanded":true}]},{"id":"7bea907aec3a1389acf5cb643e","topic":"代码规范","expanded":true,"children":[{"id":"2388e6cd575bc9e57d6649bf83","topic":"typedef","expanded":true,"children":[{"id":"967bf236c98b77280bed1981bf","topic":"使用 LNode* 来表示使用的是一个节点","expanded":true},{"id":"2c8b8facde7bc758b73c9a8a14","topic":"使用 LinkList 来表示使用的是一个链表","expanded":true}]},{"id":"05b8b7a133eb106cf452eb20e1","topic":"malloc","expanded":true,"children":[{"id":"a79ac6d3c9f9f875c3b779add8","topic":"malloc 动态分配结点","expanded":true,"code":{"lang":"c","code":"(LNode*)malloc(sizeof(LNode))","tokens":[[{"text":"(","darkColor":"#BAB5A8"},{"text":"LNode","darkColor":"#DEDBD2"},{"text":"*)","darkColor":"#BAB5A8"},{"text":"malloc","darkColor":"#6EC0DF"},{"text":"(sizeof(","darkColor":"#BAB5A8"},{"text":"LNode","darkColor":"#DEDBD2"},{"text":"))","darkColor":"#BAB5A8"}]]}}]},{"id":"230b8cde0bdab40ed5866ac7de","topic":"结构体","expanded":true,"children":[{"id":"b539ed06b2086a7942ed49f98d","topic":"LNode 结构体定义","expanded":true,"code":{"lang":"c","code":"typedef struct LNode{\n    ElemType data;\n    struct LNode *next;\n}LNode, *LinkList;","title":"LNode","tokens":[[{"text":"typedef","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" LNode","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ElemType data","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" LNode ","darkColor":"#DEDBD2"},{"text":"*","darkColor":"#BAB5A8"},{"text":"next","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"},{"text":"LNode","darkColor":"#DEDBD2"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"*","darkColor":"#BAB5A8"},{"text":"LinkList","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}]]}}]}]},{"id":"79e967b71e786a9cc1f8d9130f","topic":"按位序插入","expanded":true,"children":[{"id":"64cbb07c006b08871ff9ebb242","topic":"按位序插入（带头节点插入法）","expanded":true,"children":[{"id":"689a8ea7b1fbfb990c1aa8fe1b","topic":"找到第i - 1 个节点","expanded":true},{"id":"78ba3bd7c88a82fd6a7ac96890","topic":"然后插入一个新的节点","expanded":true}]},{"id":"f7dbad348fca94bcf8295b19c8","topic":"按位序插入（不带头节点插入法）","expanded":true,"children":[{"id":"f828dc65429bed0ba7daca564f","topic":"不带头节点的链表，处理第1个节点的时候需要特殊处理","expanded":true}]}]},{"id":"45e9a8a1942a9ac00291e85221","topic":"插入","expanded":true,"children":[{"id":"f8f8a630bf8bea6452f7ea9348","topic":"后插节点","expanded":true,"children":[{"id":"7d6b0bd2cfb92fdf7f0c491bcf","topic":"比较简单，直接malloc然后赋值、更新指针","expanded":true}]},{"id":"fbdadfd0b6f8a49d5afc3ab840","topic":"前插节点","expanded":true,"children":[{"id":"b7ea549fd4d81ed55b96daf31b","topic":"需要用一个小的巧方法","expanded":true,"children":[{"id":"b85a2f6eb4ab86b0c1b46a06fd","topic":"对节点p后面插入一个后继节点s","expanded":true},{"id":"d3f9b9bd12b9a5a44c0ccb9aef","topic":"把节点p的数据移动到节点s里面去","expanded":true},{"id":"a349db45e3d9ea3b2d95faf8dd","topic":"把新的数据放到p里面","expanded":true}]}]}]},{"id":"2808e45a92eb61750760892b34","topic":"删除","expanded":true,"children":[{"id":"58f8644c47b86f69f3d1cac9f7","topic":"按位序删除","expanded":true,"children":[{"id":"0d6a5492d31be138fa40b98004","topic":"ListDelete(LinkList &L, int i, ElemType &e)","expanded":true},{"id":"defa5407a4d8cd2ecd7f78648b","topic":"其中的e需要返回删除的数据","expanded":true}]},{"id":"6d79d46691293b85c942e97dc4","topic":"指定节点删除","expanded":true}]},{"id":"1cb9c8164b4811faef714aba9f","topic":"查找","expanded":true,"children":[{"id":"427829f1178ad470d8cae95fff","topic":"按位查找","expanded":true,"children":[{"id":"e219027efb7ba0075fb93b92cc","topic":"O(n)","expanded":true}]},{"id":"c83b953669d8fb1a018939234e","topic":"按值查找","expanded":true,"children":[{"id":"0c4a6edd727898c46b79d94126","topic":"O(n)","expanded":true}]}]},{"id":"1de98efde9e8ce03d5c03a139f","topic":"建立","expanded":true,"children":[{"id":"cefb0435041b132265c80833c1","topic":"尾插法","expanded":true},{"id":"0f094e7f8d788bd773c4780fb3","topic":"头插法","expanded":true}]}]},{"id":"14a9a20c47fa9878a8ac2aa0ef","topic":"双链表","expanded":true,"children":[{"id":"aa0cb52e-7689-4eb0-9f66-9d6c87976eec","topic":"双链表在单链表的基础上添加了前驱节点","expanded":true},{"id":"d47c9c34-1455-4c81-848e-7c18828de51e","topic":"插入：需要修改前节点的next和后节点的prior，后设置新节点的next和prior","expanded":true},{"id":"cd32b6e0-a565-4eff-9247-6d5cdaf272a1","topic":"删除：先设置前节点的next=next->next，再设置后节点的prior = prior->prior，删除中间","expanded":true}]},{"id":"d977a43b-d81e-4881-92db-41ab6d1037a2","topic":"循环链表","expanded":true,"children":[{"id":"a21d0b52-96bb-4b69-892f-cb00e71f02cb","topic":"链表中最后一个节点指向头结点","expanded":true},{"id":"b464c3c5-51e2-4b39-ae14-1f0327966e34","topic":"循环单链表","expanded":true},{"id":"746a28f2-12ce-4b2a-ac83-8edc784eeb43","topic":"循环双链表","expanded":true}]},{"id":"bc43cc83-2f98-44e9-bdf9-f7744a821c2b","topic":"静态链表","expanded":true,"children":[{"id":"04e57580-1abc-4e2f-9325-9fbebfbb59b6","topic":"线性结构+顺序存储","expanded":true},{"id":"3fb57980-29cc-4288-b155-3795599db414","topic":"用顺序表的形式进行存储空间开辟","expanded":true}]},{"id":"3de63311-4bfc-49ed-8fc1-1ce43fa49dd1","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"c7bb13dd-ff5a-4909-a3e3-8180fb075dcd","topic":"16*2、21、09大、12大、15大、19大","expanded":true}]}]},{"id":"8b7a7762e7aadf049eb86b0c10","topic":"堆栈","expanded":true,"children":[{"id":"1ff96fe9-6155-4b83-8753-b63dd181fbb4","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"93eb7d62-4201-40b6-a3cc-c274427d96ca","topic":"09、10、11、13、17、18、20、22","expanded":true}]},{"id":"83b8308bc0aac272a3ceb82f96","topic":"一种操作受限的线性表，可顺序可链式","expanded":true,"children":[{"id":"b922072f-e423-4f95-b6cd-1f209b98c149","topic":"只允许在线性表的一端进行插入和删除","expanded":true}]},{"id":"b1cb33915a1a9781cb020a6a94","topic":"n个不同元素的输入队列，一共有多少种输出队列（Catalan公式）","expanded":true,"children":[{"id":"031a882d9c0bc6b1a45e893674","topic":"","expanded":true,"children":[{"id":"2c8aa1e4787a83009e99bbe286","topic":"n = 2 -> 2\nn = 3 -> 5\n...","expanded":true}],"formula":{"tex":"\\frac{1}{n+1} C_{2n}^n","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><msubsup><mi>C</mi><mrow><mn>2</mn><mi>n</mi></mrow><mi>n</mi></msubsup></mrow><annotation encoding=\"application/x-tex\">\\frac{1}{n+1} C_{2n}^n</annotation></semantics></math></span>"}}]},{"id":"75bbf861b86ac22bda15c8f65f","topic":"顺序栈","expanded":true,"children":[{"id":"0d896a690b8910267e00aad24a","topic":"SqStack 定义","expanded":true,"children":[{"id":"5d8a72550578d0e2dca929ac24","topic":"注意初始化top = 0，则说明top指向栈顶元素的下一个元素","expanded":true},{"id":"07d84ff2e61aae78e21489cb96","topic":"如果top = -1，则说明top指向栈顶元素","expanded":true}],"code":{"lang":"c","code":"#define MaxSize 50          //定义栈中元素的最大个数\ntypedef struct {\n    Elemtype data[MaxSize]; //存放栈中元素\n    int top;                //栈顶指针\n} SqStack;","title":"SqStack","tokens":[[{"text":"#define ","darkColor":"#C699E0"},{"text":"MaxSize","darkColor":"#6EC0DF"},{"text":" ","darkColor":"#C699E0"},{"text":"50","darkColor":"#E2B159"},{"text":"          //定义栈中元素的最大个数","darkColor":"#908B7E"}],[{"text":"typedef","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#C699E0"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#C699E0"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    Elemtype ","darkColor":"#DEDBD2"},{"text":"data","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"MaxSize","darkColor":"#DEDBD2"},{"text":"];","darkColor":"#BAB5A8"},{"text":" //存放栈中元素","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" top","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"                //栈顶指针","darkColor":"#908B7E"}],[{"text":"} SqStack","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}]]}}]},{"id":"f1ba20b9944bb0d6432288ef7b","topic":"共享栈","expanded":true,"children":[{"id":"36aa4fa2da69ad08c48eea9e34","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0422521432d0fa.png","width":289,"height":107},"children":[{"id":"e7cac864a3ebcde9ed1849f060","topic":"作用：","expanded":true,"children":[{"id":"162b63efa2c95e5434305b790f","topic":"节省存储空间","expanded":true},{"id":"a7cb1762185a56a7efadc994b2","topic":"降低了上溢的可能性","expanded":true,"children":[{"id":"8eab6fc02cfb06e8edd97af9b9","topic":"只有两个栈都满才会上溢","expanded":true}]}]}]}]},{"id":"2808549bc0f826ebcd7a983835","topic":"链表栈","expanded":true,"children":[{"id":"fdc91c31061a1786ae299b6e27","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2dcf505b12c408.png","width":291,"height":137}}]},{"id":"8b697a86c11b6cf383f35b0f04","topic":"所有的递归实现改为非递归实现都需要使用栈","expanded":true,"children":[{"id":"8af844b56f09d68b129908cac6","topic":"错！","expanded":true,"children":[{"id":"d128b6d1c0e8e64c5feaab6a97","topic":"斐波那契数列可以用动态规划","expanded":true}]}]}]},{"id":"87f812170f391a64b9849ad6e4","topic":"队列","expanded":true,"children":[{"id":"6cc3a77c-111a-4e27-8e12-7b8778b57cce","topic":"一种操作受限的线性表，可顺序可链式","expanded":true,"children":[{"id":"295409d9-223a-4ce3-a3db-42e6c8d19c7b","topic":"只允许在线性表的一端进行插入，另一端进行删除","expanded":true}]},{"id":"ac2b8bd390eab36cd2ff781732","topic":"性质","expanded":true,"children":[{"id":"95283b1174ab8aa8bf9e28f2f0","topic":"队头删除元素，队尾插入元素（头删尾插）","expanded":true,"children":[{"id":"6b2b3ed50fba78f0d7f9396544","topic":"所以是队尾先行，然后队头紧跟","expanded":true}]},{"id":"edcb0091e188095420721b4e31","topic":"尾部向后扩展的线性结构","expanded":true},{"id":"1c8b7022d72a4995d8a59b8edb","topic":"front -= 1; rear += 1","expanded":true}]},{"id":"0dda9e4ec769c321b9d01bd51e","topic":"普通队列","expanded":true,"children":[{"id":"79980aed9b0a874bdf11887356","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-79147caa99211f.png","width":490,"height":164},"children":[{"id":"5c379b9c-983c-4b46-95e2-c86f494abdfc","topic":"判断队空","expanded":true,"children":[{"id":"dca7a990-3b50-4cbf-a9d4-55711c59c515","topic":"Q.front == Q.rear == 0","expanded":true}]},{"id":"6518f12d-b787-4f64-bf94-27726d7c4b36","topic":"判断队满","expanded":true,"children":[{"id":"5c1ac44e-414a-44a1-ab29-772feedb67eb","topic":"Q.rear == MaxSize && Q.front == 0","expanded":true},{"id":"c289da81-a842-430d-894b-1781907fd795","topic":"Q.rear == MaxSize 代表队列不可再插入元素","expanded":true,"style":{"background":"#D0D0D0"}}]},{"id":"f24ad308-4546-452a-91b7-8e57293257e8","topic":"顺序存储","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]}]},{"id":"a5a92e50e5d901a3ac058acd1c","topic":"循环队列","expanded":true,"children":[{"id":"62c964ea6739f29e907e2924d6","topic":"如果队列没有使用“循环功能”，rear > front","expanded":true},{"id":"5a7bb33d0f6a0779c2d8681cc6","topic":"如果队列使用了“循环功能”, front > rear","expanded":true},{"id":"aca94c24e58b71ad9aaaebffbe","topic":"判断队空和队满","expanded":true,"children":[{"id":"b5e9129d44780c4c40c5493bac","topic":"1. 牺牲一个存储单元","expanded":true,"children":[{"id":"67ea9014427a0090a85ba8781a","topic":"队满：Q.front == (Q.rear+1)%MaxSize","expanded":true},{"id":"7d9a6801ebc9cbc9af824bbbb9","topic":"队空：Q.front == Q.rear","expanded":true},{"id":"6d3aeaab8028472744e8597344","topic":"队列长度：(Q.rear - Q.front + MaxSize)%MaxSize","expanded":true}]},{"id":"554957f2dcdb9f037ab8fbad3a","topic":"2. 记录长度","expanded":true,"children":[{"id":"d5ba70d071688a646cc59abf2d","topic":"队满：Q.front == Q.rear && len == n","expanded":true},{"id":"414996a6ad88cd2559802aecd1","topic":"队空：Q.front == Q.rear && len == 0","expanded":true}]},{"id":"f57ad01f598b71ab4d5deaf0fb","topic":"3. 增加tag","expanded":true,"children":[{"id":"541973a5dd394efc6416baa3cb","topic":"队满：Q.front == Q.rear && tag == 1","expanded":true},{"id":"efcb708045b9e6c7dd50b9a9ed","topic":"队空：Q.front == Q.rear && tag == 0","expanded":true}]}]},{"id":"b3b81760765ac3873ac0bb29ea","topic":"基本操作","expanded":true,"children":[{"id":"a268a9b056cb0b4e8c7d5b5c4b","topic":"初始化：Q.front = Q.rear = 0","expanded":true},{"id":"e268db21c24933504a2edb87b8","topic":"插入元素：Q.rear == (Q.rear + 1)%MaxSize","expanded":true},{"id":"6baba765a028db32d8d7eb0b6c","topic":"删除元素：Q.front == (Q.front + 1)%MaxSize","expanded":true},{"id":"c1daf22b6439f8c00c69190a32","topic":"队列长度：(Q.rear - Q.front + MaxSize)%MaxSize","expanded":true}]},{"id":"7d7133b9-28e1-4a6e-9fc0-31f90791d4e3","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-654ef8dd342204.png","width":532,"height":224}}]},{"id":"5e8bde429bcba2b02d1519a36b","topic":"链式队列","expanded":true,"children":[{"id":"604bba58585bc97a47887a931a","topic":"最好用带头节点的形式，方便编写","expanded":true}]},{"id":"9f8b4b7cba3983894ed8a87988","topic":"双端队列","expanded":true,"children":[{"id":"1daa4c127cfb823f092048a966","topic":"输入受限的双端队列","expanded":true},{"id":"1b1bbf069d5bbaff9b0f293acb","topic":"输出受限的双端队列","expanded":true,"children":[{"id":"cfc91772c6f8afdc9ffe283d17","topic":"这种队列难度较高","expanded":true}]}]},{"id":"dffbe884836bcaac4c7a5bc503","topic":"程序中需要多个队列 or 堆栈","expanded":true,"children":[{"id":"92a9a965d45a721e798ab9a37f","topic":"使用链式，就不容易分配不合理","expanded":true}]},{"id":"9f90da5f-bb52-4736-910d-5ae1583db547","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"1f4ba1f3-1d3a-41a8-9a7c-00ac60d74a71","topic":"10、11、14、16、18、21、19大","expanded":true}]}]},{"id":"19e8e9b8196b1fa85fad5acd40","topic":"应用","expanded":true,"children":[{"id":"9c6d1de7-0bf3-4985-b300-6149563952f9","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"8e017032-94b9-4c5b-a308-28d5f6c8b6c5","topic":"09、12、14、15","expanded":true,"children":[{"id":"d5849e7c-973f-4890-bd2a-55c2efeb935a","topic":"掌握需要门槛，会了就是简单题，需要多做题多总结思考","expanded":true}]}]},{"id":"8d6a4916060a7a426b3c890a05","topic":"括号匹配","expanded":true,"children":[{"id":"29f864da-a4f2-4284-ba64-5d7f288ab4ab","topic":"使用堆栈，匹配 [[()][()]]","expanded":true}]},{"id":"f4dbb65a77fa0acbacd158acc6","topic":"表达式求解","expanded":true,"children":[{"id":"672b028e873a4932168ebaeb0c","topic":"中缀","expanded":true},{"id":"fd7bb7e89a7b308d63e1dbdb10","topic":"后缀","expanded":true},{"id":"b62bc8063a490641deff1b1da5","topic":"前缀","expanded":true}]},{"id":"9ddb3dd4a20a98184532694947","topic":"机算","expanded":true,"children":[{"id":"0d5b6d20cfdaf1d04254ab5af1","topic":"由表达式求值","expanded":true,"children":[{"id":"1f5b4c0baa9b5799ca6b38a3ab","topic":"表达式手算（后/前缀）","expanded":true,"children":[{"id":"64b8760edc99fce2c239590ebe","topic":"比较简单，直接算即可","expanded":true}]},{"id":"24a754ef-f050-433c-8745-b9a7ce82bd61","topic":"机算","expanded":true,"children":[{"id":"f58924dd1d59624adfbaebd223","topic":"后缀表达式的机算","expanded":true,"children":[{"id":"f858763ff8c85a1daea35ba08f","topic":"使用堆栈，从左往右扫描。出现数字push进入堆栈。出现运算就pop两个数字，然后算出来后再push进去。","expanded":true}]},{"id":"504beeddbf5b594d0504393cd0","topic":"前缀表达式的机算","expanded":true,"children":[{"id":"387b76d16c4942d7415fda4466","topic":"从右往左，同理","expanded":true},{"id":"c449d21b7a3b119d6e568843e3","topic":"注意：在pop后数字的次序需要特别注意（和后缀是相反的）","expanded":true}]}]}]},{"id":"74c9083b5bba6c7ed82b285a9e","topic":"求表达式","expanded":true,"children":[{"id":"d3fa240e22281b738b04ab0ff8","topic":"步骤","expanded":true,"children":[{"id":"6fba539242abe3c4b4878949a5","topic":"用一个栈来存储运算符","expanded":true},{"id":"0a3a06d559d9f8753346086b3d","topic":"遇到‘数’，直接输出","expanded":true},{"id":"32bb789e67b8e381bad1c94de8","topic":"遇到‘操作符’，如果与栈顶元素比较优先级，如果优先级低，直接入栈。否则，弹出所有比这个符号优先级高或者相等的操作符","expanded":true},{"id":"22496c2d1db885195372f995e1","topic":"遇到‘界限符’，遇到\"(\"，直接入栈。如果遇到\")\"，就依次弹出操作数，直到找到\"(\"为止","expanded":true}]}]},{"id":"0098fc8bd7f9787a52dd08ea0b","topic":"直接计算","expanded":true,"children":[{"id":"e13b265fc83aabf3997cc9d7d9","topic":"一个操作数栈","expanded":true},{"id":"569841fd742a79d3d0a839a3dc","topic":"一个符号栈","expanded":true}]},{"id":"8fe9e424-883b-4ca5-85fd-a4ce3bc649e1","topic":"举例","expanded":true,"children":[{"id":"3e9834f5-724d-432c-8948-90bde47c63ba","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-89ba2c814c4359.png","width":492,"height":483}}]}]},{"id":"977a44ad4f29d74218fc8be6c3","topic":"递归的应用","expanded":true,"children":[{"id":"97fb70b8-acda-43ee-aed7-7e2c3d91f015","topic":"将递归转为栈实现","expanded":true}]},{"id":"20ea183b5f6878f7dc6f8b781a","topic":"队列应用","expanded":true,"children":[{"id":"945b1371b5ebf02f1d2c59c43c","topic":"树、图的BFS遍历","expanded":true},{"id":"56a874b08f6bdcd16e616a29b5","topic":"在OS、CO的应用","expanded":true,"children":[{"id":"d048b449ae29a012591c193ddb","topic":"FCFS","expanded":true,"children":[{"id":"500b01d8175ad205a008baefd0","topic":"FCFS算法的基础就是队列","expanded":true}]},{"id":"e3fb244a127971bd395ffac603","topic":"缓冲区队列","expanded":true,"children":[{"id":"4979f63803ea1eb8b308793e2a","topic":"缓和CPU、主存和IO设备的速度差距","expanded":true}]}]}]}]},{"id":"995ad7689709080df91c0b47f3","topic":"特殊矩阵的压缩存储","expanded":true,"children":[{"id":"504841ac70f8061db172c876fa","topic":"一维数组","expanded":true},{"id":"143bd965be3b12bcd45118d5ad","topic":"二维数组","expanded":true,"children":[{"id":"a79aed998a98e8b13ba4f999fa","topic":"行优先存储","expanded":true},{"id":"0f09b21a0b1a9f8bbe449abbab","topic":"列优先存储","expanded":true}]},{"id":"4a59604da048dceb1ba79a9ca7","topic":"普通矩阵","expanded":true,"children":[{"id":"aaabf3c6c4fba102e37958f358","topic":"下标通常是从1开始的，而数组的下标通常从0开始","expanded":true}]},{"id":"822b77d5b10aa9a98785db0288","topic":"特殊矩阵","expanded":true,"children":[{"id":"efd991c291a82bd1cce6ebc8f8","topic":"对称矩阵","expanded":true,"children":[{"id":"0d193c7f07eb5ec84aeb6a1043","topic":"只需要存储对角线+上/下三角区域","expanded":true,"formula":{"tex":"a_{i,j} = a_{j,i}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><msub><mi>a</mi><mrow><mi>i</mi><mo separator=\"true\">,</mo><mi>j</mi></mrow></msub><mo>=</mo><msub><mi>a</mi><mrow><mi>j</mi><mo separator=\"true\">,</mo><mi>i</mi></mrow></msub></mrow><annotation encoding=\"application/x-tex\">a_{i,j} = a_{j,i}</annotation></semantics></math></span>"}},{"id":"7ba9a4d90519ef96a0cfc99551","topic":"行优先/列优先","expanded":true},{"id":"3c7b2c070688362873bae8e3ae","topic":"数据总数：n(1+n)/2","expanded":true}]},{"id":"0e3bc1715d699745aa140b9d2b","topic":"三角矩阵","expanded":true,"children":[{"id":"3b7b2d45cce9e24f250b89a3e7","topic":"和对称矩阵类似，加一个位置（数组的最后一位）来存另外三角的常量值","expanded":true,"children":[{"id":"ccb0a8ec-a963-48a5-8ee1-23be0303618d","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-9452dfba019587.png","width":238,"height":132}}]}]},{"id":"91cab86e36c84d74e67c3a3e4a","topic":"三对角矩阵（带状矩阵）","expanded":true,"children":[{"id":"6be8531c1c0ad3614a215b10e6","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-940a563346eba5.png","width":340,"height":268}}]},{"id":"c79b9b7590a90ea13634d852de","topic":"稀疏矩阵","expanded":true,"children":[{"id":"45096d82306a9dfa87590bcc1f","topic":"使用一个顺序存储的三元组","expanded":true,"children":[{"id":"86893ea652d86290b8630808f5","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7fd9756f8f8040.png","width":524,"height":502}}]},{"id":"297af260cc6a621e05f2086da2","topic":"十字链表法","expanded":true,"children":[{"id":"779be6854f8b7f574e4d7bc645","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2a094d2ceb1d24.png","width":415,"height":207},"children":[{"id":"ce48fc69-06f0-46a3-a308-e28fbeb2d488","topic":"图那章讲解","expanded":true}]}]}]}]},{"id":"f34a076f-670d-4639-8ea1-06b9e5b55322","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"090c7d5c-d6ec-49c2-91f3-8b405bcd990e","topic":"16、17、18、20、21","expanded":true,"children":[{"id":"d1bc3b06-c483-41c5-9f23-ba0426000e3b","topic":"计算偏多","expanded":true}]}]}]},{"id":"0a3d8dc7-a96c-46d9-b967-9510febfe284","topic":"END","expanded":true}]},"summaries":[{"id":"493b143a921ab0f00251886a7b","parentId":"5c8831735a6820106a71893d07","start":0,"end":0,"label":"缺一不可，n=0 叫空表"},{"id":"65c9162dff8a081cb204bae842","parentId":"53ea799e4bfa45b0da42caaae6","start":4,"end":5,"label":"注意length需要修改，传入是引用"},{"id":"ae88dcee41995ee067f408cba4","parentId":"a5a92e50e5d901a3ac058acd1c","start":0,"end":1,"label":"与普通队列的front、rear功能同步"},{"id":"518994f5de7b264f4707993a01","parentId":"f4dbb65a77fa0acbacd158acc6","start":0,"end":2,"label":"中缀转后缀：左优先原则\n中缀转前缀：右优先原则"},{"id":"d1274a98-3acd-4a08-9f54-0e5775489898","parentId":"9ddb3dd4a20a98184532694947","start":2,"end":2,"label":"问你这个栈需要多大"},{"id":"2663b14b-e106-42be-84de-a2320be455e2","parentId":"995ad7689709080df91c0b47f3","start":2,"end":2,"label":"大题技巧：当没告诉你下标从哪里开始"}],"boundaries":[{"id":"5f2a14cf704b910b3299495e4e","parentId":"aca94c24e58b71ad9aaaebffbe","start":0,"end":0,"label":"最常考"}]}}},{"id":"67ddbcb1-85c9-4478-a0aa-580e9fdcd971","topic":"第四章 串","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/data-structures/ds-00-sheet3","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"ds-00-sheet3","title":"第四章 串","structure":"timeline-h","theme":"auto","root":{"id":"cfe9dfe8267900723c65392c97","topic":"第四章 串","expanded":true,"children":[{"id":"435283d5-6c52-4bd0-8d0f-6b7aed7a0fa8","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"883b494c-4ecf-447d-ad57-fc5d41435c02","topic":"15、19","expanded":true}]},{"id":"cc695d94b129d41ebec5da16ba","topic":"定义","expanded":true,"children":[{"id":"56c99866cbeab829cb043afbcc","topic":"串","expanded":true,"children":[{"id":"5ad97783afb883a9f9be994854","topic":"就是string","expanded":true}]},{"id":"8c5a3c669b5bd7ef52974822b2","topic":"主串 & 子串","expanded":true,"children":[{"id":"d65808de-6a6b-4fa3-b768-e763f888cf1a","topic":"子串是主串中任意连续字符组成的子序","expanded":true}]},{"id":"f2afcc33-5009-4e90-9e69-4ba23c04ddc7","topic":"主串 & 模式串","expanded":true,"children":[{"id":"3ce6a516-d2eb-42cd-802a-fca08950bd98","topic":"KMP中的概念","expanded":true}]},{"id":"07afe820-2795-4e97-bdc9-3270cde87677","topic":"两种实现","expanded":true,"children":[{"id":"ec85a6a4-618d-4533-bf71-e3201c19266e","topic":"std::string s","expanded":true,"children":[{"id":"9c8f6d44-9465-42ae-9959-4ecfcc6bc358","topic":"s.at(i)","expanded":true,"children":[{"id":"584a26d7-b3aa-469c-b7f8-5d2400c7f6ba","topic":"功能上比较类似vector<char>","expanded":true}]}]},{"id":"960762c8-a86d-4d46-9b4c-c72894b0d555","topic":"char * s","expanded":true,"children":[{"id":"17be4337-7632-46f7-a4e2-ca26ce51ef63","topic":"s[i]","expanded":true}]}]}]},{"id":"534ad1b148d8c2153199a8ea1e","topic":"课本要求的基本操作函数","expanded":true,"children":[{"id":"25026d8e-2dac-4106-9ffd-491e31ea5fe3","topic":"StrAssign(&T, chars): 赋值操作。把串T赋值为chars。","expanded":true},{"id":"3487ba30-219a-4a22-b112-98ad95fa30de","topic":"StrCopy(&T, S): 复制操作。由串S复制得到串T。","expanded":true},{"id":"7565603b-5fe5-4f1d-a03f-15e55fc0dd96","topic":"StrEmpty(S): 判空操作。若S为空串，则返回TRUE，否则返回FALSE。","expanded":true},{"id":"46f35937-8e99-47e5-8b25-7fbf6dc3564a","topic":"StrLength(S): 求串长。返回串S的元素个数。","expanded":true},{"id":"6819388b-abc4-4d59-8c92-252642cbabef","topic":"ClearString(&S): 清空操作。将S清为空串。","expanded":true},{"id":"e2ab189b-8596-4d54-8316-8534edf2d9d7","topic":"DestroyString(&S): 销毁串。将串S销毁 (回收存储空间) 。","expanded":true},{"id":"ec9476e1-edd2-4af2-8264-de6fc19ff30f","topic":"Concat(&T, S1, S2): 串联接。用T返回由S1和S2联接而成的新串。","expanded":true},{"id":"773c67a0-701b-4b91-b119-a7fd1148837b","topic":"SubString(&Sub, S, pos, len): 求子串。用Sub返回串S的第pos个字符起长度为len的子串。","expanded":true},{"id":"6c947eb1-68c2-4480-ba8a-1d89625ca657","topic":"Index(S, T): 定位操作。若主串S中存在与串T值相同的子串，则返回它在主串S中第一次出现的位置:否则函数值为0。","expanded":true,"style":{"background":"#FDD834"}},{"id":"6241f8bd-dfa4-4fda-a394-5731b5c29e1f","topic":"StrCompare(S, T): 比较操作。若S>T，则返回值>0: 若S=T，则返回值=0: 若S<T，则返回值<0。","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"8dbab40dd318b38510d82a6fb4","topic":"存储结构","expanded":true,"children":[{"id":"e6cbed40861ae9115429ab6fc5","topic":"顺序存储","expanded":true,"children":[{"id":"d3d8fb2bfc3a7ccbc8345be2e2","topic":"静态数组实现\n（定长顺序存储）","expanded":true,"children":[{"id":"65095eb3a98b21a9be57dbef45","topic":"char ch[MAX_SIZE]","expanded":true},{"id":"5afa7978dc797098347d0a6c67","topic":"SString 定义","expanded":true,"code":{"lang":"c","code":"#define MAXLEN 255          //预定义最大串长为255\ntypedef struct {\n    char ch[MAXLEN];        //每个分量存储一个字符\n    int length;             //串的实际长度\n} SString;","title":"SString","tokens":[[{"text":"#define ","darkColor":"#C699E0"},{"text":"MAXLEN","darkColor":"#6EC0DF"},{"text":" ","darkColor":"#C699E0"},{"text":"255","darkColor":"#E2B159"},{"text":"          //预定义最大串长为255","darkColor":"#908B7E"}],[{"text":"typedef","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#C699E0"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#C699E0"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"char","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"ch","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"MAXLEN","darkColor":"#DEDBD2"},{"text":"];","darkColor":"#BAB5A8"},{"text":"        //每个分量存储一个字符","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" length","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"             //串的实际长度","darkColor":"#908B7E"}],[{"text":"} SString","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}]]}}]},{"id":"5c281dfe4d9b590d1751ebadb8","topic":"动态数组实现\n（堆分配存储）","expanded":true,"children":[{"id":"f24b8829375a9db1051709a6a9","topic":"char * ch","expanded":true}]},{"id":"06a8aa2095488cf7a333292c61","topic":"四种顺序存储方案","expanded":true,"children":[{"id":"a8a988d300aac9a8c69e196c87","topic":"默认使用最后一种方式存储（教材上的）","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ea1dfe20f1d0e1.png","width":364,"height":180}}]}]},{"id":"f3b84dc4f8fa1bc0585909aa7d","topic":"链式存储","expanded":true,"children":[{"id":"981b7f173119289c285cf9c447","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0e5d915741c88d.png","width":385,"height":223}}]}]},{"id":"4c0914b6d5d9fa4c7e525aa8a5","topic":"字符串的模式匹配算法","expanded":true,"children":[{"id":"399afeab3749da9347ae29df26","topic":"主串 N","expanded":true,"children":[{"id":"e7fbe3068e59168807aa2b5f03","topic":"模式串 M","expanded":true}]},{"id":"90abd09e010a609822332b0ebd","topic":"朴素模式匹配算法","expanded":true,"children":[{"id":"1f8971b03fa98015c205685075","topic":"暴力解决问题","expanded":true},{"id":"1dc3e959-3e11-4a83-aae0-ee010c74e7c1","topic":"时间复杂度：O(NM)","expanded":true}]},{"id":"564b993d-331b-43bc-abbe-dd467296e956","topic":"KMP","expanded":true,"children":[{"id":"d815e50f-9ec4-4e08-9c65-4026e2ef51ff","topic":"可以避免暴力重复匹配 O(N+M)","expanded":true}]}]},{"id":"738b306dac49344be2503a476d","topic":"KMP算法","expanded":true,"style":{"background":"#EEEEEE"},"children":[{"id":"275a4fafbf5b7d7250a9b9360d","topic":"使用next数组来进行模式串指针的回溯","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-382a1ce404f7c2.png","width":438,"height":183}},{"id":"f19b4cbd5518168332c089055e","topic":"KMP的next数组算法：","expanded":true,"style":{"background":"#EEEEEE"},"children":[{"id":"e3b9f555e7b8c2158472c8e7c3","topic":"图示","expanded":true,"hyperlink":"https://www.bilibili.com/video/BV1jb411V78H?from=search&seid=1484468344086384340&spm_id_from=333.337.0.0","style":{"background":"#EEEEEE"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-3b77ea9547c22d.png"}}]},{"id":"104bce08e48b1d158dc53a2afc","topic":"KMP的nextval算法：","expanded":true,"style":{"background":"#EEEEEE"},"children":[{"id":"51c8af933488a53ed2a5c80164","topic":"图示","expanded":true,"hyperlink":"https://www.bilibili.com/video/BV1uJ411s7br?from=search&seid=1484468344086384340&spm_id_from=333.337.0.0","style":{"background":"#EEEEEE"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-cdc4e735329e4e.png"}}]}]},{"id":"a37e93ad-ff4f-43ea-9e9c-3eb75229f05d","topic":"KMP 可能的考法","expanded":true,"children":[{"id":"5d3b5807ad38b9e966d6cad3fc","topic":"KMP求next数组","expanded":true,"children":[{"id":"1a0885ce7a9ac1861f04ab480c","topic":"next[1]无脑写0","expanded":true},{"id":"26792215597bba77a8d6394e04","topic":"next[2]无脑写1","expanded":true},{"id":"d91b131bcd4adf3498d3e87f23","topic":"考点：手写next数组\n(不需要优化，左边只要\n对得上就可以）","expanded":true,"icons":["emoji:😄"],"children":[{"id":"7cc861d95ab9f1bec2126acb22","topic":"练习：1. google","expanded":true,"children":[{"id":"b39a53d2e248feac479cfa35f3","topic":"011121","expanded":true}]},{"id":"9789ecf7be28e8c8d6ff8b354d","topic":"练习：2. ababaa","expanded":true,"children":[{"id":"5779f0b36dfb546f21bffa2225","topic":"011234","expanded":true}]},{"id":"dc6b367e05eaa7b18a31aae08c","topic":"练习：3. aaaab","expanded":true,"children":[{"id":"eb0b6f9328a8bdbe19c6d98afb","topic":"01234","expanded":true}]},{"id":"7249304ff4cb620840c3dba48b","topic":"做法：建议使用21年的做法，去看最长相同前后缀子串长度+1","expanded":true}]},{"id":"931ab9a0f2dbb2cc08eae94ef4","topic":"没考过：next数组的代码\n/nextval数组","expanded":true,"icons":["emoji:😕"],"children":[{"id":"e2f9c799430b37e0bca399442c","topic":"代码实现next[]","expanded":true,"code":{"lang":"c","code":"//求模式串T的next数组\nvoid get_next(SString T, int next[]) {\n    int i = 1, j = 0;\n    next[1] = 0;\n    while (i < L.length) {\n        if (j == 0 || T.ch[i] == T.ch[j]) {\n            ++i; ++j;\n            //若 pi=pj，则next[j+1]=next[j]+1\n            next[i] = j;\n        } else {\n            //否则令j=next[j]，循环继续\n            j = next[j];\n        }\n    }\n}","title":"get_next","tokens":[[{"text":"//求模式串T的next数组","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"get_next","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"SString ","darkColor":"#DEDBD2"},{"text":"T","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"next","darkColor":"#D5C5AA"},{"text":"[]","darkColor":"#8EA4E2"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" i ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" j ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"next","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"i ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"L","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"j ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":" ","darkColor":"#DEDBD2"},{"text":"||","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"T","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"ch","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"T","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"ch","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#DEDBD2"},{"text":"])","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"++","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#BAB5A8"},{"text":"//若 pi=pj，则next[j+1]=next[j]+1","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"next","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" j","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"else","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#BAB5A8"},{"text":"//否则令j=next[j]，循环继续","darkColor":"#908B7E"}],[{"text":"            j ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"next","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#DEDBD2"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}},{"id":"442bba0cb458fcad4165da05db","topic":"如何求nextval数组：","expanded":true,"children":[{"id":"06a911703a2a03090913bbc588","topic":"算出next数组，从左到右扫描next数组，去消除冗余项","expanded":true},{"id":"c86ac4fddd8b597082d928a4e2","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ed0a51d4ea60e1.png","width":295,"height":110}},{"id":"c46ba3e0ce299295664498d3a8","topic":"代码","expanded":true,"code":{"lang":"cpp","code":"//nextval数组的求法:\n//先算出 next 数组\n//然后令 nextval[1]=0\nfor(int j=2; j<T.length; j++) {\n    if(T.ch[next[j]]==T.ch[j])\n        nextval[j]=nextval[next[j]];\n    else\n        nextval[j]=next[j];\n}","title":"nextval","tokens":[[{"text":"//nextval数组的求法:","darkColor":"#908B7E"}],[{"text":"//先算出 next 数组","darkColor":"#908B7E"}],[{"text":"//然后令 nextval[1]=0","darkColor":"#908B7E"}],[{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":"=","darkColor":"#BAB5A8"},{"text":"2","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":"<","darkColor":"#BAB5A8"},{"text":"T","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"length","darkColor":"#D5C5AA"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":"++)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"T","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"ch","darkColor":"#D5C5AA"},{"text":"[","darkColor":"#BAB5A8"},{"text":"next","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"]]==","darkColor":"#BAB5A8"},{"text":"T","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"ch","darkColor":"#D5C5AA"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"nextval","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"]=","darkColor":"#BAB5A8"},{"text":"nextval","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"next","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"]];","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"else","darkColor":"#8EA4E2"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"nextval","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"]=","darkColor":"#BAB5A8"},{"text":"next","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}]}]},{"id":"18acb73b-31dc-4c4d-abc3-f9f5ec8e557e","topic":"KMP计算index：看视频","expanded":true}]},{"id":"5af76b99-c709-47fe-9d42-9d1a64de8676","topic":"END","expanded":true}]}}}},{"id":"98de4b0a-4ff0-4eca-a38b-b202a9ed978e","topic":"第五章 树","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/data-structures/ds-00-sheet4","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"ds-00-sheet4","title":"第五章 树","structure":"timeline-h","theme":"auto","root":{"id":"49aac89ae8d945cf985329e7f1","topic":"第五章 树","expanded":true,"children":[{"id":"ecf97e0d6418ab080b0bdb3f79","topic":"基本概念","expanded":true,"children":[{"id":"3f8be8de6719ec774a582be356","topic":"基本术语","expanded":true,"children":[{"id":"0f19fed0f079b5b91d49eb93eb","topic":"节点关系","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-312a46666fcaf6.png","width":228,"height":187},"children":[{"id":"5ccab6e704592b73ba3368bbde","topic":"祖先 & 子孙","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"bb492c9eb63a66de2d0d7addbe","topic":"双亲 & 孩子","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"e70aa0cd5609fd01e6815b77bc","topic":"兄弟","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"1b8ab49d7138211acdc4780d2b","topic":"分支结点/非终端节点","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"8d5b8ab2c469e202fdacb82a5b","topic":"度 > 0","expanded":true}]},{"id":"d03b1eb604fabc4b1829f9910c","topic":"叶子结点/终端节点","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"65cb25c7cfdb3f3a0b253a9def","topic":"度 = 0","expanded":true}]}]},{"id":"85a931fe5a0aeba77d77e9f7c1","topic":"属性","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"e3ab70e75d39a90456cd5b6d57","topic":"结点的层次","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"743aa14b4a2ae66bb7836a641d","topic":"从根节点（第一层）开始，越往下层数+1","expanded":true}]},{"id":"0aea5fa8eb3b1edd62069b5a41","topic":"结点的高度","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"711825fa785a414633fb2b7f6d","topic":"叶子高度为0，自底向上","expanded":true}]},{"id":"08d20111-4e92-449d-9058-78ca4a5459db","topic":"结点的深度","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"4ae25b4c-b845-4919-aed6-1575bbc77063","topic":"根节点深度为0，自顶向下","expanded":true}]},{"id":"620b12334df9c42b4ec26beecb","topic":"树的高度/深度","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"430ad03029f9ee3b90d3d806e1","topic":"结点的层次的最大值","expanded":true}]},{"id":"a73b7ca63dcbce3127831b6601","topic":"树的路径长度","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"710802b18a39001b39b1fb07ec","topic":"从根节点开始到每个结点的路径长度之和","expanded":true,"children":[{"id":"b1127d20-efe4-4b77-b8a9-80030a75237c","topic":"结点总数的二叉树，完全二叉树的路径长度最小","expanded":true}]}]},{"id":"357ae075a94a5831a112987752","topic":"结点的度","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"9ce92761cd8bcb10ce5fcb9772","topic":"结点拥有的孩子数目","expanded":true}]},{"id":"0deb8086e8a8bffa4160496161","topic":"树的度","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"9e5a39aefe88f56cce7fab2d78","topic":"树中所有结点的度的最大值","expanded":true}]}]},{"id":"f8fba25e00f9b62f5d170b88c7","topic":"路径","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"d5db770f15fb199c6070c9d36a","topic":"两结点之间的路径 (vector<Node>)","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"532b606b09182d83abccf9a5a4","topic":"路径是由第一个结点到第二个结点的路径，从上到下的","expanded":true},{"id":"66088d54d40a09232c892821c1","topic":"路径是两个节点之间经过的结点序列构成的","expanded":true}]},{"id":"1a6a61f6d43b8e5ae79b8b8eeb","topic":"两结点之间的路径长度 (int)","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c599d94c16a9ba86946e691253","topic":"路径上边的个数","expanded":true}]}]},{"id":"e8a8f007b4d91c7af642cab42a","topic":"有序树和无序树","expanded":true,"children":[{"id":"926a8bdca97b0ad1c3542be461","topic":"有序树：","expanded":true,"children":[{"id":"e1992d15795b33f859442b9510","topic":"每个结点的孩子节点顺序是固定的，不可换","expanded":true},{"id":"fe86c230-f394-4714-9cc9-c36e5b6ab33e","topic":"比如：struct是Node* left, Node* right","expanded":true}]},{"id":"f0583a610d1b1a7cf15efb744b","topic":"无序树：","expanded":true,"children":[{"id":"11796dbf918824994e223814fe","topic":"每个结点的孩子节点顺序可以改变","expanded":true},{"id":"9b4e0542-66d7-469c-8ad9-41c7b2b3c2bd","topic":"比如：struct是vector/set<Node*>","expanded":true}]}]}]},{"id":"a1ca8570ce3b6a6431df19c2e8","topic":"森林","expanded":true,"children":[{"id":"654e1ce7-dd46-4241-8f2c-8f6cc1fcc59f","topic":"多个互不相交的树的【集合】","expanded":true}]},{"id":"944806914fbbbfe9f85bbbe85c","topic":"考点","expanded":true,"children":[{"id":"f0b98456318b9efe0b898942d3","topic":"算结点数和高度、度的关系","expanded":true}]},{"id":"d98840d386db7a00bfd0b97f2b","topic":"m叉数的性质","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-312a46666fcaf6.png","width":228,"height":187},"children":[{"id":"0f8a3ac66cb9b9d4452b2b404c","topic":"树中节点数 = 所有节点的度数之和 + 1","expanded":true,"icons":["priority:1"],"style":{"background":"#FDD834"},"children":[{"id":"eacb4c68faca10a244540be381","topic":"除了根节点，其他节点都是某个节点的孩子","expanded":true},{"id":"b428136f7a48672c196ee8dca3","topic":"如果树的节点为n个，则所有结点度为 n-1","expanded":true},{"id":"5fdbc58b4f1b3101bc66dbed7a","topic":"也即：具有n个节点的树的边数为 n-1","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"6839f89c3d79c39ea233ba4c82","topic":"度为m的树的第i层上至多有","expanded":true,"icons":["priority:2"],"style":{"background":"#FDD834"},"children":[{"id":"255b3a789c09de730e0c8868bf","topic":"","expanded":true,"children":[{"id":"f81bb07f-fc25-44cf-9cbc-2941822423f7","topic":"（想象成满m叉树）","expanded":true}],"formula":{"tex":"m^{i-1} \\text{ 个节点}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><msup><mi>m</mi><mrow><mi>i</mi><mo>−</mo><mn>1</mn></mrow></msup><mtext> 个节点</mtext></mrow><annotation encoding=\"application/x-tex\">m^{i-1} \\text{ 个节点}</annotation></semantics></math></span>"}}]},{"id":"5c3861a36048922a26599a142c","topic":"高度为h的m叉树最多有","expanded":true,"icons":["priority:3"],"style":{"background":"#FDD834"},"children":[{"id":"324adfa31b9b72439195899bdb","topic":"","expanded":true,"children":[{"id":"3a7e731d-586f-4981-b537-a9836e8fd260","topic":"（想象成满m叉树）","expanded":true}],"formula":{"tex":"1 + m + m^2 + \\dots + m^{h-1} = \\frac{1 - m^h}{1 - m} \\text{ 个节点}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mn>1</mn><mo>+</mo><mi>m</mi><mo>+</mo><msup><mi>m</mi><mn>2</mn></msup><mo>+</mo><mo>⋯</mo><mo>+</mo><msup><mi>m</mi><mrow><mi>h</mi><mo>−</mo><mn>1</mn></mrow></msup><mo>=</mo><mfrac><mrow><mn>1</mn><mo>−</mo><msup><mi>m</mi><mi>h</mi></msup></mrow><mrow><mn>1</mn><mo>−</mo><mi>m</mi></mrow></mfrac><mtext> 个节点</mtext></mrow><annotation encoding=\"application/x-tex\">1 + m + m^2 + \\dots + m^{h-1} = \\frac{1 - m^h}{1 - m} \\text{ 个节点}</annotation></semantics></math></span>"}}]},{"id":"e5bbf96809599a552295c8e461","topic":"具有n个节点的m叉树的最小高度","expanded":true,"icons":["priority:4"],"style":{"background":"#FDD834"},"children":[{"id":"3dcb934159481947d11ed87007","topic":"反解上面的h","expanded":true,"children":[{"id":"7f7b7d8cf3b8633019a3a964df","topic":"","expanded":true,"formula":{"tex":"\\log_m(n(m - 1) + 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 stretchy=\"false\">(</mo><mi>m</mi><mo>−</mo><mn>1</mn><mo stretchy=\"false\">)</mo><mo>+</mo><mn>1</mn><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">\\log_m(n(m - 1) + 1)</annotation></semantics></math></span>"}}]}]},{"id":"d85bb877-12c0-408a-a4e3-b290addb0906","topic":"举特例","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]},{"id":"bf064195-f78d-41da-aaa7-550b63e5a69d","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c8f693c3-bed2-4b69-9a59-561c3789ff8e","topic":"10","expanded":true}]}]},{"id":"cf49d1889a5bc02ac7746aed62","topic":"二叉树","expanded":true,"children":[{"id":"98093d59-6cea-4640-9306-5f138ea1f7f0","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"57d62665-65f7-4aad-a089-ec3728f4fd81","topic":"09、11、18、20、22大","expanded":true}]},{"id":"82ef8b4f-2fd0-45ee-afae-5e1c5f0050dd","topic":"逻辑结构","expanded":true,"children":[{"id":"d659e98741a8e67c38e7b9406f","topic":"有序树，每个结点至多只有两棵子树","expanded":true}]},{"id":"fd8bebc6ee38d3c40f0e6bcb25","topic":"特殊的二叉树","expanded":true,"children":[{"id":"d2f9aaf0b99a17fbf19e8a06ca","topic":"满二叉树","expanded":true,"children":[{"id":"427a5ae7518bd2279426eb34da","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c60ccc5170222a.png","width":282,"height":151}}]},{"id":"5b680966114af9b73e2e193ec9","topic":"完全二叉树","expanded":true,"children":[{"id":"bfaa3f297898fd913aa35a6fbc","topic":"和满二叉树的结点编号一样","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-3fa0cf5398143b.png","width":269,"height":144},"children":[{"id":"c6f15fa7-2cd3-4888-b2ed-076ddee26f51","topic":"三角形缺右下角","expanded":true}]}]},{"id":"ef7afcc6d538f5c4e897e99bc4","topic":"二叉排序树","expanded":true,"children":[{"id":"5f14a9fd-252b-4ad0-9516-8a0553ac0abf","topic":"二叉树中的每个结点的值一定比左孩子的大，一定比右孩子的值小","expanded":true}]},{"id":"e8a84d9973393a6c7ab6180c71","topic":"平衡二叉树","expanded":true,"children":[{"id":"1dda6c2cc08aae32aded9ba397","topic":"树上任意一个结点的左右子树\n的深度之差不超过1","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d6995cf0542b2ebf8d43b9a959","topic":"会有更高效的排序搜索效率","expanded":true,"style":{"background":"#FF9595"}}]}]}]},{"id":"2cd945860758dc8b06d608349d","topic":"二叉树的常考性质","expanded":true,"icons":["emoji:🤔"],"children":[{"id":"f50a1b6ac449e1ccb2902a9fb0","topic":"非空二叉树中度为0、1、2的\n结点个数分别为n0, n1, n2 故","expanded":true,"children":[{"id":"4eb877c111e913a86565f85728","topic":"总结点数为三种之和","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"d73be53eed990ec87511f98077","topic":"n = n0 + n1 + n2","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"f3ca00232549c1797739986b48","topic":"总结点 = 总度数 + 1","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"793a80e8b23858e4ab61cbb55f","topic":"n = 2*n2 + n1 + 1","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6e326ea4-a83a-4cb7-902e-4df4cae27b08","topic":"n个节点，总度数n-1","expanded":true}]}]},{"id":"e0fa9af68559c58d54825b413a","topic":"可推出：\n叶子节点数 = 度为2的节点数 + 1","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"fa2899ec849bd340f2ef897644","topic":"n0 = n2 + 1","expanded":true,"style":{"color":"#111111","background":"#8EDDF9"}}]}]},{"id":"5848d65fb3b908a8509b8b3acd","topic":"完全二叉树","expanded":true,"children":[{"id":"f7f9a122e318c4d4e884390dcc","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8a03d70c026f45.png","width":503,"height":146},"children":[{"id":"705e01c3-59fc-4d9d-b326-e852c4ab4255","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d4c06d85708b94.png","width":235,"height":397}},{"id":"0772d122-1500-496f-b022-ffe610f17065","topic":"22年算法题（一半）","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]}]}]},{"id":"8d59f3f2d28bf45d738bfa4349","topic":"二叉树的存储结构","expanded":true,"children":[{"id":"079aee548b3a0c3af73e6be0a2","topic":"顺序存储","expanded":true,"children":[{"id":"656b4f49b4296a348fbfe9dac0","topic":"存储方式","expanded":true,"children":[{"id":"f738acfebfaa6a1479e5580c0f","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1d3ebfa2ff4f30.png","width":411,"height":179}}]},{"id":"529b4a333f7b568dfe02fac0b8","topic":"最佳适配完全二叉树","expanded":true},{"id":"0d78d360ce9bc6a42429486f63","topic":"非完全二叉树","expanded":true,"children":[{"id":"bbeba24d37c990dd1d950b2418","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-41fd539b92ea9f.png","width":601,"height":252}}]}]},{"id":"c4f8ca237ec83e0a3af2cb6e61","topic":"链式存储","expanded":true,"children":[{"id":"e329f16993f984910149c8e09e","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7b22a0ad0006bb.png","width":476,"height":301}}]}]}]},{"id":"bc06a06c-4131-4958-a6b5-f09b50a76fc2","topic":"遍历、线索二叉树","expanded":true,"children":[{"id":"a123c587-cdc2-44b4-b9f3-48e143a9f0ce","topic":"二叉树的遍历","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-312a46666fcaf6.png","width":228,"height":187},"children":[{"id":"fb80f243-8b0e-4f93-a1b0-df2c1db86e3b","topic":"先序、中序、后序","expanded":true,"children":[{"id":"16825b5a-a7c6-48ec-951b-e727abc7b6b4","topic":"递归遍历","expanded":true},{"id":"0169cee1-276e-4b3e-953c-2214e31d6ddb","topic":"非递归","expanded":true}]},{"id":"2c903a2d-872d-48a7-b88e-d8302893f804","topic":"层次遍历","expanded":true,"children":[{"id":"c23e518b-5761-4dfc-8f06-9ba3154f6463","topic":"数据结构——二叉树先序、中序、后序及层次四种遍历（C语言版）_中序遍历_正弦定理的博客-CSDN博客","expanded":true,"hyperlink":"https://blog.csdn.net/chinesekobe/article/details/110874773"}]},{"id":"d1859ed1-d7da-4e71-a2fc-b5905235566f","topic":"知道遍历结果，能否推出树的结构？","expanded":true,"children":[{"id":"ac06d948-d808-45f9-bd4b-0f0bfc3104e4","topic":"先+中","expanded":true},{"id":"213cbda5-dbad-447b-b459-2e8ab19400c5","topic":"中+后","expanded":true},{"id":"dcc392af-fd70-4420-9cc5-6958cfa5e02c","topic":"先+后","expanded":true},{"id":"4c767d83-efae-483f-aeb2-f43e759b35e2","topic":"层+中","expanded":true}]}]},{"id":"7589d4065ee85a3999d92b65ff","topic":"线索二叉树","expanded":true,"children":[{"id":"6d1ac9bb24e8175d7190eb8591","topic":"逻辑、物理结构定死了","expanded":true,"style":{"background":"#FF9595"}},{"id":"43a888ef55d9fd42b44708c805","topic":"考点：1. 基本概念","expanded":true,"children":[{"id":"56e9da824b79bd327a693b45ca","topic":"每个二叉树都有有很多结点的指针空了，无法利用","expanded":true,"children":[{"id":"7de9462704eb9ffee9e71aad07","topic":"给二叉树的每个结点再分别设置左右两个tag标记","expanded":true,"children":[{"id":"54291c5b71a86f277048aaaf31","topic":"tag=0 表明左右指针是结点的孩子","expanded":true},{"id":"634b9a3b4958c2d6363f5ab1df","topic":"tag=1 表明左右指针是结点的前驱/后继","expanded":true}]},{"id":"fc6f566a-1fd5-423d-b9d8-4478658a9b5b","topic":"n个结点、n-1个边，n+1个空指针","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]},{"id":"1838b9c39d399aff47569854bd","topic":"代码：","expanded":true,"children":[{"id":"099899be5cf84d7a7acc198a37","topic":"ThreadNode 定义","expanded":true,"code":{"lang":"c","code":"typedef struct ThreadNode {\n    ElemType data;                 //数据元素\n    struct ThreadNode *lchild, *rchild; //左、右孩子指针\n    int ltag, rtag;                //左、右线索标志\n}ThreadNode,*ThreadTree;","title":"ThreadNode","tokens":[[{"text":"typedef","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" ThreadNode ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ElemType data","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"                 //数据元素","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" ThreadNode ","darkColor":"#DEDBD2"},{"text":"*","darkColor":"#BAB5A8"},{"text":"lchild","darkColor":"#DEDBD2"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"*","darkColor":"#BAB5A8"},{"text":"rchild","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" //左、右孩子指针","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ltag","darkColor":"#DEDBD2"},{"text":",","darkColor":"#BAB5A8"},{"text":" rtag","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"                //左、右线索标志","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"},{"text":"ThreadNode","darkColor":"#DEDBD2"},{"text":",*","darkColor":"#BAB5A8"},{"text":"ThreadTree","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}]]}}]}]},{"id":"a61b724eb9b8741afadfa825f7","topic":"2. 构造","expanded":true,"children":[{"id":"89c85e68f149a8142c397b73ee","topic":"在树的遍历中，设置前后两个结点指针，来进行前驱/后继的连接","expanded":true}]},{"id":"d56ae45541e9f68d2c4449313b","topic":"3. 代码查找前驱后继","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b169bf33bd6b1c3b8af53926dc","topic":"先序线索二叉树","expanded":true,"style":{"background":"#EEEEEE"},"children":[{"id":"fa78ac87115b5bdda182186262","topic":"前驱不好找","expanded":true,"style":{"background":"#EEEEEE"}},{"id":"1358dacef1b9de3cf586eafc6b","topic":"后继好找","expanded":true,"style":{"background":"#EEEEEE"}}]},{"id":"12ca5026d3792fd9ce6439e0b7","topic":"中序线索二叉树","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"e76bfd076d3b84e22e5f6be8aa","topic":"前驱好找","expanded":true,"style":{"background":"#8EDE99"}},{"id":"2e9b43eacf2b2016e8045a4165","topic":"后继好找","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"0299923c4b6b29cea75ae87d28","topic":"后序线索二叉树","expanded":true,"children":[{"id":"f469b2c2630a5c291900596c6f","topic":"前驱好找","expanded":true},{"id":"9c881db05b4925c869a1eb9f35","topic":"后继不好找","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"5869d3934758f8142f2bcaae48","topic":"1. 如果为根节点","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d91aa839921900ea0c18eb7fea","topic":"后继为NULL","expanded":true}]},{"id":"e4694f50a8c9f648352efa2292","topic":"2. 如果为双亲的右孩子 or 双亲的左孩子+双亲无右孩子","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"5d6b6d2fcfe9e7ded3fa88b547","topic":"后继是双亲（rtag = 1 时的rchild）","expanded":true}]},{"id":"43cb280cc23be1cee5e1696680","topic":"3. 其他情况","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"2d1a6ab5b53bc43242cfea4191","topic":"需要找到双亲右子树的第一个被遍历的节点","expanded":true,"children":[{"id":"e7f9d2adf2fbef21bc2f395ba9","topic":"无法用过指针找到","expanded":true}]}]}]}]},{"id":"0efe53ee-eab3-42b3-85a9-9464c4ff5d1e","topic":"难、没考过","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]}]},{"id":"801b370299c807a4a85efa857c","topic":"一些树的引申题目：","expanded":true,"children":[{"id":"18a94516eb08195f028e2925e3","topic":"1. 已知两节点MN，M是N的祖先，如何找从M到N的路径：","expanded":true,"children":[{"id":"9e6be930a37a9f3e652899230d","topic":"通过【后序遍历 + 辅助栈】的办法就可以找到路径","expanded":true}]},{"id":"a92816f6f2e9bc3121cd3a2da0","topic":"2. 在二叉树的前中后序遍历中，叶子结点的访问顺序","expanded":true,"children":[{"id":"43089d16bb19d5a0032be8beea","topic":"完全相同，因为叶子结点一定不是根节点，一定是子树的访问又一定是先左后右的","expanded":true}]}]},{"id":"d168e361-d818-4e04-bfaa-7561baf09193","topic":"考频：超高","expanded":true,"style":{"background":"#9C27B0"},"children":[{"id":"2f8339e3-f26a-4ecd-b707-e82dd815e84f","topic":"09-15、17*2、22、14大、17大、22大","expanded":true}]}]},{"id":"5f599383fd4b0efb04554af2d0","topic":"树与森林","expanded":true,"children":[{"id":"bbcb6537-5d8b-415e-8aac-ab6b98f235f5","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"48100f65-9c15-462e-9576-151ba312aaa0","topic":"09、11、14、16、19、20、21、22、16大","expanded":true}]},{"id":"5688129a81baef257e04abc9b2","topic":"树的存储结构","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a19273f21a384b.png","width":261,"height":220},"children":[{"id":"decba1dccc7bc987c345b98b30","topic":"普通的树的概念","expanded":true,"children":[{"id":"5b8a6d47cb9a99eadfd2197d7d","topic":"每个结点可以有n个孩子，只有一个双亲","expanded":true}]},{"id":"aa3aa6d19bba24b0a554f84aae","topic":"双亲表示法","expanded":true,"children":[{"id":"0cc86f4b8daab6895d24396aa0","topic":"图示","expanded":true,"children":[{"id":"118972b42c9bad6daf6da848c0","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-566dff7c62e247.png","width":333,"height":250}}]},{"id":"8c3b717fdf6b39aec486581af2","topic":"顺序存储","expanded":true,"children":[{"id":"43ebb995a2ba82513408485b8f","topic":"使用静态链表来存储亲子关系","expanded":true},{"id":"ab88cf22d7286b0319949a5177","topic":"代码","expanded":true,"children":[{"id":"bafaeeca33680d3fceab4b5bbe","topic":"双亲表示法代码实现","expanded":true,"code":{"lang":"c","code":"//双亲表示法的存储结构描述如下:\n#define MAX_TREE_SIZE 100       //树中最多结点数\ntypedef struct {                //树的结点定义\n    ElemType data;              //数据元素\n    int parent;                 //双亲位置域\n}PTNode;\ntypedef struct {                //树的类型定义\n    PTNode nodes[MAX_TREE_SIZE];//双亲表示\n    int n;                      //结点数\n}PTree;","title":"PTNode / PTree","tokens":[[{"text":"//双亲表示法的存储结构描述如下:","darkColor":"#908B7E"}],[{"text":"#define ","darkColor":"#C699E0"},{"text":"MAX_TREE_SIZE","darkColor":"#6EC0DF"},{"text":" ","darkColor":"#C699E0"},{"text":"100","darkColor":"#E2B159"},{"text":"       //树中最多结点数","darkColor":"#908B7E"}],[{"text":"typedef","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#C699E0"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#C699E0"},{"text":"{","darkColor":"#BAB5A8"},{"text":"                //树的结点定义","darkColor":"#908B7E"}],[{"text":"    ElemType data","darkColor":"#C699E0"},{"text":";","darkColor":"#BAB5A8"},{"text":"              //数据元素","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#C699E0"},{"text":"int","darkColor":"#74CBC4"},{"text":" parent","darkColor":"#C699E0"},{"text":";","darkColor":"#BAB5A8"},{"text":"                 //双亲位置域","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"},{"text":"PTNode","darkColor":"#C699E0"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"typedef","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"                //树的类型定义","darkColor":"#908B7E"}],[{"text":"    PTNode ","darkColor":"#DEDBD2"},{"text":"nodes","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"MAX_TREE_SIZE","darkColor":"#DEDBD2"},{"text":"];","darkColor":"#BAB5A8"},{"text":"//双亲表示","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" n","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"                      //结点数","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"},{"text":"PTree","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}]]}}]}]},{"id":"12c95aab5db8d363fa15283aa7","topic":"链式存储","expanded":true,"children":[{"id":"da1b651e339a04fd530ecb94e7","topic":"在结点中设置指针来存储链接关系","expanded":true}]}]},{"id":"dce93beb603a34e506747ae87a","topic":"孩子表示法","expanded":true,"children":[{"id":"e0785f933a1874610afd1aee83","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-142a0b3fe315a8.png","width":278,"height":236},"children":[{"id":"de187ba13bfadde0be497a888e","topic":"就是图的邻接链表存储","expanded":true}]}]},{"id":"ba2b2f6224aa3c583deb2b36a5","topic":"孩子兄弟表示法","expanded":true,"children":[{"id":"a99b780b3f98314383855af166","topic":"设置兄弟指针左走是孩子，右走是兄弟","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-061721f677a278.png","width":235,"height":280},"children":[{"id":"7e789bb25a38afd5d359baee0b","topic":"代码","expanded":true,"code":{"lang":"c","code":"typedef struct CSNode {\n    ElemType data;                       //数据域\n    struct CSNode *firstchild,*nextsibling; //第一个孩子和右兄弟指针\n}CSNode,*CSTree;","title":"CSNode","tokens":[[{"text":"typedef","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" CSNode ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ElemType data","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"                       //数据域","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" CSNode ","darkColor":"#DEDBD2"},{"text":"*","darkColor":"#BAB5A8"},{"text":"firstchild","darkColor":"#DEDBD2"},{"text":",*","darkColor":"#BAB5A8"},{"text":"nextsibling","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" //第一个孩子和右兄弟指针","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"},{"text":"CSNode","darkColor":"#DEDBD2"},{"text":",*","darkColor":"#BAB5A8"},{"text":"CSTree","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}]]}}]}]},{"id":"b8f9c9b1531a23105cce8ad590","topic":"也就是连通无环图","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]},{"id":"e70ba4feedf8300666bf9992dd","topic":"树的遍历","expanded":true,"children":[{"id":"648b69ec3a88c9b0a0cd8a7e8f","topic":"先根","expanded":true,"children":[{"id":"431aaa3652b88d0f3290a9dc21","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ed4f67ae9272c5.png","width":452,"height":294}}]},{"id":"f17940c51d6acb9e4d8d0b2ab3","topic":"后根","expanded":true,"children":[{"id":"a5ab3b13cf1b05f37fd29b5736","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7156617d192ebe.png","width":458,"height":298}}]},{"id":"7219f58a9fdab622dee69b766c","topic":"层次","expanded":true,"children":[{"id":"6f4b334a52080e8a3ef269e3eb","topic":"BFS+使用队列进行辅助","expanded":true}]}]},{"id":"bcda52183c997825e36799eabc","topic":"森林","expanded":true,"children":[{"id":"f03aef15d15837cca0b24a2ba9","topic":"森林就是很多颗树并排在一起","expanded":true,"children":[{"id":"d70a05784d2b6fee0c4a5bf66a","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-124631e1523fd4.png","width":376,"height":227}}]},{"id":"e70a382eaaf880a05ee8a967e0","topic":"把多个树的根节点作为兄弟节点，进行【孩子兄弟表示法】连接","expanded":true}]},{"id":"81c815a0396807fb54174bb309","topic":"森林的遍历","expanded":true,"children":[{"id":"f1aa53d6daa829f071ed981208","topic":"先序","expanded":true,"children":[{"id":"c3ba1ef6a9e87096e56a281efa","topic":"效果等同于对这颗二叉树进行先序遍历","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2307efff6b358e.png","width":406,"height":209}}]},{"id":"96eaf936277864f75fd4e88172","topic":"后序","expanded":true,"children":[{"id":"d179e1bb2b8b1ff9b5687a273e","topic":"效果等同于对这颗二叉树进行中序遍历","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0b0fcf1832297c.png","width":412,"height":212}}]}]}]},{"id":"2f7961da6be82af4965819db7e","topic":"二叉数的应用","expanded":true,"children":[{"id":"d098b450e43b64228bcbc8addf","topic":"二叉排序树\n（BST）","expanded":true,"children":[{"id":"d8ea0c11eb2bb5982f69b9c511","topic":"每个结点：左节点值 < 根节点值 < 右节点值","expanded":true},{"id":"2e04a4c2-75d3-447a-87fe-e4048d09acb0","topic":"作用：","expanded":true,"children":[{"id":"951df645-a340-4919-84ef-ea7063413c96","topic":"用来进行搜索，”排序“体现在建树的过程","expanded":true}]},{"id":"c469e15bcd681402d2e39bff00","topic":"算法：","expanded":true,"children":[{"id":"d4082165ba18034af170fa9e3b","topic":"搜索","expanded":true,"children":[{"id":"023a1871b1a8cf7aa12cabb09e","topic":"进行比较，确定向左 or 向右","expanded":true}]},{"id":"d0780e8d9c98c7c8dce2e96771","topic":"插入","expanded":true,"children":[{"id":"2c9880d01a1a5003b054b9c554","topic":"如果树为空，则直接插入","expanded":true},{"id":"310b652df4fbd550836ff9e8b6","topic":"树不为空","expanded":true,"children":[{"id":"b60b6aeb104a9091ae98e85cd5","topic":"和结点值进行比较，如果比它小，就插到左边","expanded":true},{"id":"595bd1fd041b7aa4994eebd559","topic":"如果比它大，就插到右边","expanded":true},{"id":"47aa928f31aabfccd74949f322","topic":"插入时如果发现对应边的结点不为NULL，则继续比较","expanded":true}]}]},{"id":"a72a214614c9265609bbd8f25d","topic":"构造","expanded":true,"children":[{"id":"7b4bcfd697bb2b35d7aa8819ec","topic":"从零开始一个一个插","expanded":true}]},{"id":"c03a4065a8f913c8c7a91ba87b","topic":"删除","expanded":true,"children":[{"id":"dc980ce336887a124f9b1a59cd","topic":"如果是叶子结点，直接删","expanded":true},{"id":"552a28b2fe49a58d83c92aa986","topic":"如果只有单子树，则把子树移动上来","expanded":true},{"id":"fe5ad24de0daccc55df7a9d134","topic":"既有左子树又有右子树","expanded":true,"children":[{"id":"42693d4ed9b97ea4fa1c4b020e","topic":"用直接前驱","expanded":true,"children":[{"id":"853b19877d5af5a2e39558fecb","topic":"左子树的最右","expanded":true}]},{"id":"ed399b05c3aaaca7068a684531","topic":"用直接后继","expanded":true,"children":[{"id":"702bd95b14b8a656aab80b8f72","topic":"右子树的最左","expanded":true}]}]}]}]},{"id":"b7d979dc7589c6b666ee791a4d","topic":"ASL","expanded":true,"children":[{"id":"8f9a4184fec901e0e562089d23","topic":"平均查找长度","expanded":true,"children":[{"id":"86d80534c3e9035326defb398a","topic":"查找次数一定不会超过高度，所以BST越矮越好","expanded":true},{"id":"01fa0d770d98465da5113b2685","topic":"查找成功","expanded":true,"children":[{"id":"f1691de1499bc7c96346d820e8","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c6b2a4ef9a273c.png","width":458,"height":218}}]},{"id":"4c9bfedecf09a5c656a04ad234","topic":"查找失败","expanded":true,"children":[{"id":"487a471797ba585fc1514bddbf","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c4fb0f0c3f1a77.png","width":461.87,"height":223.4},"children":[{"id":"8e8aad50b29838a482a4e81722","topic":"失败节点视为等概率，不要钻牛角尖","expanded":true}]}]}]}]}]},{"id":"b9f872fc2c7aac77a52559ab35","topic":"平衡二叉树 \n（AVL）","expanded":true,"children":[{"id":"57c969cdbb1913f72f395ac8a0","topic":"定义：树上面任意一个节点的左右子树的高度差不超过1","expanded":true,"children":[{"id":"bc29aafb1148cf3d882a69d23d","topic":"即左子树高 - 右子树高 = -1, 0, 1","expanded":true}]},{"id":"8c7aef06097bc3c20a24091008","topic":"节点数据结构","expanded":true,"children":[{"id":"dd186956838aa2f7fd878af8a2","topic":"AVLNode 定义","expanded":true,"code":{"lang":"c","code":"//平衡二叉树的结点\ntypedef struct AVLNode {\n    int key;        //数据域\n    int balance;    //平衡因子\n    struct AVLNode *lchild,*rchild;\n}AVLNode,*AVLTree;","title":"AVLNode","tokens":[[{"text":"//平衡二叉树的结点","darkColor":"#908B7E"}],[{"text":"typedef","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" AVLNode ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" key","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"        //数据域","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" balance","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"    //平衡因子","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"struct","darkColor":"#8EA4E2"},{"text":" AVLNode ","darkColor":"#DEDBD2"},{"text":"*","darkColor":"#BAB5A8"},{"text":"lchild","darkColor":"#DEDBD2"},{"text":",*","darkColor":"#BAB5A8"},{"text":"rchild","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"},{"text":"AVLNode","darkColor":"#DEDBD2"},{"text":",*","darkColor":"#BAB5A8"},{"text":"AVLTree","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}]]}}]},{"id":"3a5a2f27b3ca77d5206698b551","topic":"插入","expanded":true,"children":[{"id":"822b1b3bdb985c31acbe0956d7","topic":"插入一个节点过后，调整最小的不平衡子树","expanded":true},{"id":"3c7b1378b119da393e755a20fb","topic":"四种不同的调整","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"a27a1e4dc3ea8dec99ae480fac","topic":"LL","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"11c9b42bd4387c39adc1899298","topic":"右旋，BL < B(※) < BR < A < AR","expanded":true,"style":{"background":"#FF9595"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-91acd6bca52fd4.png","width":662,"height":332},"children":[{"id":"3169f57f4149ad3bb47d98e4f6","topic":"代码实现就是改几个指针","expanded":true}]}]},{"id":"31785e4ca6184f48aa41b8a94c","topic":"RR","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"bc39878998cb1b242c6ebb97f5","topic":"左旋，AL < A < BL < B(※) < BR","expanded":true,"style":{"background":"#FF9595"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-74bbaf935f83a2.png","width":656,"height":311},"children":[{"id":"f27ba0548fe8bb1e732fcbad01","topic":"代码实现就是改几个指针","expanded":true}]}]},{"id":"735a90a54c493d785ceb095004","topic":"LR","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"1b49a91d638b1decabe348d32c","topic":"先对B左旋再对A右旋，BL < B < CL < C(※) < CR < A < AR","expanded":true,"style":{"background":"#FF9595"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4b5ce69385013c.png","width":658,"height":311}}]},{"id":"7a7b9729a63b3dff9fe948f211","topic":"RL","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"d6e965d13dca2f3cef6c4bfcbb","topic":"先对B右旋再对A左旋，AL < A < CL < C(※) < CR < B < BR","expanded":true,"style":{"background":"#FF9595"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d44af6bc369694.png","width":661,"height":248}}]}]}]},{"id":"e3781c40aa8ab1e87d9619b181","topic":"查找效率","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3738fefdcbd8ddece73258a4e8","topic":"树上任意一个结点的左右子树高度只差不超过 1，设n(h)表示为深度为h的平衡树中含有的最少节点数","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"f16bde7f3fa85639e7723ad605","topic":"故有n(h)  = n(h-1) + n(h-2) + 1","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"412d500b-3ca3-4560-a72e-e1342cf6a02a","topic":"第二类数学归纳法","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]}]},{"id":"ebaa63d249e9ec907edbe8f9ba","topic":"平衡二叉树高度为h，最少的节点数为n，最多的节点数为m：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3aaa7c5dd10a1d8472814a2d5e","topic":"h","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"c8ab2fa365b81f6828e139d37c","topic":"0","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"71093e22023aa034db23bb294d","topic":"1","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"23d97549705a4309cf577b9fab","topic":"2","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"32da9ba2d2c916941251ab337a","topic":"3","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"222b73f90f28ce187f2bb9b68a","topic":"4","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"3aab70e3c7eabb1a97ea7a2d9d","topic":"...","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7f090bc449988a12799218a40f","topic":"","expanded":true,"style":{"background":"#8EDE99"},"formula":{"tex":"O(\\log_2 n) = k","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mi>n</mi><mo stretchy=\"false\">)</mo><mo>=</mo><mi>k</mi></mrow><annotation encoding=\"application/x-tex\">O(\\log_2 n) = k</annotation></semantics></math></span>"}}]}]}]}]}]}]}]},{"id":"907a25d4985a892e2c0448dc22","topic":"n","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"f958b988d318502a9c22498d36","topic":"0","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"322b4ce1ff09fb4c4fad58726e","topic":"1","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"a0ab56587c5994854dd46a271f","topic":"2","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"459add1de5ca845b15ea3af56b","topic":"4","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"5778e90e9dfb6b6af89f686e30","topic":"7","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"743b808b0248c711b4f149e0df","topic":"...","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"3628c585bb7bcbee9659689e64","topic":"n","expanded":true,"style":{"background":"#BA69C8"}}]}]}]}]}]}]}]},{"id":"ff36f348-a193-4aa5-8695-34596aa055f7","topic":"m","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"08aedd73-fb5d-4e1c-9f2a-9b9d09bfeb1a","topic":"0","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"0373bc8b-047c-4c37-a8fc-21a338310cec","topic":"1","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"532dfd53-cd58-43ae-a42d-5f8583ca1d27","topic":"3","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"371fa1ce-c2cc-4e67-bc11-868d61ca87e8","topic":"7","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"b4d7c390-e6ef-4296-a71a-02fc80c5a01b","topic":"15","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"9199d4c0-115a-4f20-b8b4-f2d674a4f3db","topic":"...","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"bbca894e-1f61-4ee0-83cd-24b44af0eb1d","topic":"","expanded":true,"style":{"background":"#7986CB"},"formula":{"tex":"k^2 - 1","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><msup><mi>k</mi><mn>2</mn></msup><mo>−</mo><mn>1</mn></mrow><annotation encoding=\"application/x-tex\">k^2 - 1</annotation></semantics></math></span>"}}]}]}]}]}]}]}]}]},{"id":"7e0b87382b59beda1e5f68a3e4","topic":"故平衡二叉树的查找效率为：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"084a034e3df9fe46e1c05839ab","topic":"","expanded":true,"style":{"background":"#8EDDF9"},"formula":{"tex":"O(\\log_2 n)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mi>n</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(\\log_2 n)</annotation></semantics></math></span>"}}]}]}]},{"id":"747be83f-989a-4109-a734-5b71cbc6f78f","topic":"红黑树 RBT","expanded":true,"children":[{"id":"551b84ad-ef73-4001-aca9-4d04765883ff","topic":"详细：第七章查找","expanded":true}]},{"id":"a66fb271-6303-4401-969d-33fd2fdc2ff2","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"30dc59c6-1ecf-4b9f-a589-d5024c81efe3","topic":"09、10、11、12、13*2、15、18-21","expanded":true}]},{"id":"77c43657-6857-4a29-a3cc-d23c35d26fa9","topic":"【注】这一小节位于王道书本第7.3章【树形查找】，建议在这里先学了，以免第七章查找的繁杂知识点过多","expanded":true,"style":{"background":"#7986CB"}}]},{"id":"865abcc2da2a5eb096f28addd7","topic":"哈夫曼树","expanded":true,"children":[{"id":"1b08d291-af0a-4fee-a709-7a3d48e62691","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"b0474782-cc82-4d6a-8af8-2b2d5f23975c","topic":"14、15、17、18、19、21、22、12大、20大","expanded":true}]},{"id":"6a07cbb6-7c87-4ded-b02a-170ea323d9c0","topic":"定义：","expanded":true,"children":[{"id":"ac5035da-db3c-4983-8da9-1b0c2d0c8024","topic":"在二叉树中，每一个节点都赋予一个具有意义的数值，称为该节点的权","expanded":true}]},{"id":"1e5cafc5-c8a7-4709-9340-fc2c764f06b9","topic":"前缀编码：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"bb9346b3-4c6e-4de5-abad-3589658df381","topic":"前缀编码的定义是在一个字符集中，任何一个字符的编码都不是另一个字符编码的前缀。","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"76832e8d-79d9-440f-9e7f-1d1e593deb00","topic":"哈夫曼编码就是前缀编码","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"b7bb4a22e0299ea502eaf92ffa","topic":"带权路径长度","expanded":true,"children":[{"id":"b300b9e3-1bb9-48ba-a36d-a0f4d1c23d6b","topic":"结点的：","expanded":true,"children":[{"id":"edfe3ac6-ae69-4d0b-989c-e831eb3c6e0a","topic":"根到结点的边数 * 权值","expanded":true}]},{"id":"6605e6e3-f5e5-4175-b04d-1fe8c9e2e8d5","topic":"树的：","expanded":true,"children":[{"id":"2d7c84be-8994-476a-8c7e-3306dbfc5e9e","topic":"树中所有【叶子】节点带权路径长度之和","expanded":true,"formula":{"tex":"WPL = \\sum_{i=1}^{n} w_i l_i","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>W</mi><mi>P</mi><mi>L</mi><mo>=</mo><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></munderover><msub><mi>w</mi><mi>i</mi></msub><msub><mi>l</mi><mi>i</mi></msub></mrow><annotation encoding=\"application/x-tex\">WPL = \\sum_{i=1}^{n} w_i l_i</annotation></semantics></math></span>"}}]}]},{"id":"bdd8f45ef10929454ad5ba9afc","topic":"定义","expanded":true,"children":[{"id":"f9f3555c-adbb-4136-8981-06528f6a922a","topic":"n个【带权叶节点】的二叉树中，WPL最小的二叉树称为哈夫曼树","expanded":true}]},{"id":"c07bbad379098ad8a81a6bc8ff","topic":"构造","expanded":true},{"id":"39788274b338e1beec3d4bbbf6","topic":"编码","expanded":true},{"id":"523a3340-7c09-4729-8bb9-f818d7ea3060","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-146749adbf12a6.png","width":543.06,"height":407.41}}]},{"id":"5b9b97bfe0ab07674deabaa703","topic":"并查集","expanded":true,"children":[{"id":"a8982de322a857cb9ef6697c22","topic":"最优雅的算法、帮派战斗、知乎","expanded":true,"hyperlink":"https://zhuanlan.zhihu.com/p/93647900/"},{"id":"a83b5d698b6bbfa8a5063bae52","topic":"定义：","expanded":true,"children":[{"id":"6446e397-01af-4775-9fce-96a53cadc0d9","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a6dd9c44d87f7b.png","width":406,"height":225},"children":[{"id":"ed823629-140c-470c-8585-5983eb8a2fcb","topic":"存储结构：可以采用森林存储","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8934141433e20c.png","width":462,"height":232}},{"id":"8d1c80f6-b3d2-4534-adb7-fee363ee03f2","topic":"具体存储方法：采用双亲表示法","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8695512fa61bef.png","width":460,"height":288}}]},{"id":"b5583261e38949da32a71bde0a","topic":"就是离散数学中的集合的概念","expanded":true,"children":[{"id":"ff3a0198473b4dde4af8b95602","topic":"只支持查找和合并","expanded":true}]}]},{"id":"65d865843acafa68a2e58bb502","topic":"代码：","expanded":true,"children":[{"id":"ffe7df31-fd74-4f06-8aea-bf9b3a4404dc","topic":"初始化","expanded":true,"children":[{"id":"f66a7a3ed94a0376aa78d80cc7","topic":"代码实现","expanded":true,"code":{"lang":"c","code":"/**\n * 并查集的结构定义如下:\n */\n#define SIZE 100\nint UFSets[SIZE];               //集合元素数组 (双亲指针数组)\n/**\n * 并查集的初始化操作 (S 即为并查集) :\n */\nvoid Initial (int S[]) {\n    for(int i=0; i<size; i++)   //每个自成单元素集合\n        S[i] = -1;\n}","title":"UFSets & Initial","tokens":[[{"text":"/**","darkColor":"#908B7E"}],[{"text":" * 并查集的结构定义如下:","darkColor":"#908B7E"}],[{"text":" */","darkColor":"#908B7E"}],[{"text":"#define ","darkColor":"#C699E0"},{"text":"SIZE","darkColor":"#6EC0DF"},{"text":" ","darkColor":"#C699E0"},{"text":"100","darkColor":"#E2B159"}],[{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"UFSets","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"SIZE","darkColor":"#DEDBD2"},{"text":"];","darkColor":"#BAB5A8"},{"text":"               //集合元素数组 (双亲指针数组)","darkColor":"#908B7E"}],[{"text":"/**","darkColor":"#908B7E"}],[{"text":" * 并查集的初始化操作 (S 即为并查集) :","darkColor":"#908B7E"}],[{"text":" */","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Initial","darkColor":"#6EC0DF"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#D5C5AA"},{"text":"[]","darkColor":"#8EA4E2"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" i","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" i","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":"size","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" i","darkColor":"#DEDBD2"},{"text":"++)","darkColor":"#BAB5A8"},{"text":"   //每个自成单元素集合","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"cc09d745e81a897deb2a4af02a","topic":"查找：","expanded":true,"children":[{"id":"800af2e1296b33953bc71ada14","topic":"Find 代码实现","expanded":true,"children":[{"id":"83182ef7ebe9d6295dd3fb50ac","topic":"优化：路径合并","expanded":true,"children":[{"id":"22d9b89f3faa4c82c602185fce","topic":"把集合最后变成类似“菊花树”的样子","expanded":true,"code":{"lang":"c","code":"/**\n * 合并 (路径压缩)\n */\nint find(int x) {\n    if(x==fa[x])\n        return x;\n    else {\n        fa[x] = find(fa[x]);    //父节点设为根节点\n        return fa[x];           //返回父节点\n    }\n}\n//以上代码常常简化为一行:\nint find(int x) {\n    return x== fa[x] ? x : (fa[x] = find(fa[x]));\n}","title":"find（路径压缩）","tokens":[[{"text":"/**","darkColor":"#908B7E"}],[{"text":" * 合并 (路径压缩)","darkColor":"#908B7E"}],[{"text":" */","darkColor":"#908B7E"}],[{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"find","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"x","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":"fa","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#DEDBD2"},{"text":"])","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" x","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"else","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"fa","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"find","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"fa","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#6EC0DF"},{"text":"]);","darkColor":"#BAB5A8"},{"text":"    //父节点设为根节点","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"fa","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#DEDBD2"},{"text":"];","darkColor":"#BAB5A8"},{"text":"           //返回父节点","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"//以上代码常常简化为一行:","darkColor":"#908B7E"}],[{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"find","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"x","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" x","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"fa","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"?","darkColor":"#BAB5A8"},{"text":" x ","darkColor":"#DEDBD2"},{"text":":","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"fa","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"find","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"fa","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#6EC0DF"},{"text":"]));","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}],"code":{"lang":"c","code":"//Find操作 (函数在并查集 S 中查找并返回包含元素 x 的树的根) :\nint Find(int S[], int x) {\n    while(S[x]>=0)          //循环寻找 x 的根\n        x = S[x];\n    return x;               //根的 s[] 小于0\n}","title":"Find","tokens":[[{"text":"//Find操作 (函数在并查集 S 中查找并返回包含元素 x 的树的根) :","darkColor":"#908B7E"}],[{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Find","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#D5C5AA"},{"text":"[]","darkColor":"#8EA4E2"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"x","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#DEDBD2"},{"text":"]>=","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":"          //循环寻找 x 的根","darkColor":"#908B7E"}],[{"text":"        x ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"x","darkColor":"#DEDBD2"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" x","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"               //根的 s[] 小于0","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"af2bfbc656dbd6f2fcfd6a56d3","topic":"合并：","expanded":true,"children":[{"id":"0f2968319aa871b07e3b1968ac","topic":"Union 代码实现","expanded":true,"code":{"lang":"c","code":"/**\n * Union操作 (函数求两个不相交子集合的并集) :\n */\nvoid Union(int S[], int Root1, int Root2) {\n    //要求Root1与Root2是不同的，且表示子集合的名字\n    S[Root2] = Root1;   //将根Root2连接到另一根Root1下面\n}","title":"Union","tokens":[[{"text":"/**","darkColor":"#908B7E"}],[{"text":" * Union操作 (函数求两个不相交子集合的并集) :","darkColor":"#908B7E"}],[{"text":" */","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Union","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#D5C5AA"},{"text":"[]","darkColor":"#8EA4E2"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Root1","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Root2","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#BAB5A8"},{"text":"//要求Root1与Root2是不同的，且表示子集合的名字","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"Root2","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" Root1","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":"   //将根Root2连接到另一根Root1下面","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}]},{"id":"7776e4ae-6105-4c9a-a8a0-8d48e5ab9b81","topic":"优化：","expanded":true,"children":[{"id":"c85adf06-6e96-445d-a08f-5ce3b8cb358d","topic":"查找的时间复杂度和树高一样，所以要控制树高","expanded":true},{"id":"996586da-0a0f-44a0-bf09-a0d9b208271d","topic":"每次并查集的合并都是小树并到大树里面","expanded":true,"children":[{"id":"139ddc1c-ae34-4afe-8c9c-7eba1a71a0f7","topic":"用根节点的”绝对值“来表示当前结点个数，例如-3即为这个树里面有3个节点","expanded":true},{"id":"f118ef73-44fb-44a9-ac74-964e536e1cd8","topic":"合并后树高不会超过 ⌊log2n⌋+1","expanded":true,"children":[{"id":"378ca391-0318-4a79-9a96-a100f71c296c","topic":"证明：数学归纳法","expanded":true}]},{"id":"61d51809-1050-4447-b55e-2627cad17b36","topic":"实现代码","expanded":true,"code":{"lang":"c","code":"void Union_2(int S[], int Root1, int Root2) {\n    if(Root1 == Root2) return;\n    if(S[Root2] > S[Root1]) {\n        // 如果Root2中的节点数更少，Root2合并到Root1\n        S[Root1] += S[Root2]; // 修改根节点的节点总数\n        S[Root2] = Root1; // Root2合并过去\n    }\n    else {\n        // Root1中的节点数更少，Root1合并到Root2\n        S[Root2] += S[Root1]; // 修改根节点的节点总数\n        S[Root1] = Root2;\n    }\n}","title":"Union_2","tokens":[[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Union_2","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#D5C5AA"},{"text":"[]","darkColor":"#8EA4E2"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Root1","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Root2","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"Root1 ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" Root2","darkColor":"#DEDBD2"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"Root2","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"Root1","darkColor":"#DEDBD2"},{"text":"])","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#BAB5A8"},{"text":"// 如果Root2中的节点数更少，Root2合并到Root1","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"Root1","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"+=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"Root2","darkColor":"#DEDBD2"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 修改根节点的节点总数","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"Root2","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" Root1","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"},{"text":" // Root2合并过去","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"else","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#BAB5A8"},{"text":"// Root1中的节点数更少，Root1合并到Root2","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"Root2","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"+=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"Root1","darkColor":"#DEDBD2"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 修改根节点的节点总数","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"S","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"Root1","darkColor":"#DEDBD2"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" Root2","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}],"formula":{"tex":"\\text{时间复杂度 } O(\\log_2 n)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mtext>时间复杂度 </mtext><mi>O</mi><mo stretchy=\"false\">(</mo><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mi>n</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">\\text{时间复杂度 } O(\\log_2 n)</annotation></semantics></math></span>"}}]},{"id":"ef95ab7d-7f0d-4c3f-b4c6-54b6d6ac738a","topic":"并查集的究极优化","expanded":true,"children":[{"id":"b6a79052-0f19-46f0-81ce-539fed13f1d7","topic":"压缩路径","expanded":true,"children":[{"id":"19f8cc57-0156-4d74-882e-4589021e0c03","topic":"代码","expanded":true,"children":[{"id":"68d546cc-5f7d-460a-847f-155f13460d64","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-51caaf472cbf22.png","width":691,"height":374}}]},{"id":"c7a6a69a-63d4-45fc-9350-ef66e156867c","topic":"时间复杂度","expanded":true,"children":[{"id":"ade91922-73c5-4e2a-a14e-f7e38ae154b8","topic":"在常见的n的取值范围内是O(4)","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-fd75647cd8eac3.png","width":648,"height":71}}]}]},{"id":"51ca2526-9caf-423f-b0ab-7d55d22b6368","topic":"优化的总结","expanded":true,"children":[{"id":"afe09b21-fdac-4e4d-8af0-10b744bc6bfe","topic":"初始版本：","expanded":true,"children":[{"id":"446945f4-0132-4b8f-82fd-93494ad8b6c0","topic":"用数组、双亲表示法来描述元素之间的集合关系。根节点为-1，非根节点指向父节点下标。","expanded":true}]},{"id":"1e28b856-5d47-428c-91cb-48650da3c948","topic":"Union优化后：","expanded":true,"children":[{"id":"d3d8907e-3ed9-43f7-9388-0f0cd24ef213","topic":"用根节点的负值表示一棵树的节点总数，每次Union的时候是用小树合并到大树根节点下面","expanded":true}]},{"id":"ad7f58d4-4912-491c-ac04-78b89e6010df","topic":"Find优化后：","expanded":true,"children":[{"id":"db8fd20d-01d7-4983-b49c-96fc73522058","topic":"使用了压缩路径的策略，每次Find操作先找到了x所属的根节点，再将查找路径上的所有节点都直接挂载到根节点下面。","expanded":true}]},{"id":"2c5d8da4-aacd-4fb7-86bf-27a1bf2c862a","topic":"最坏时间复杂度比较","expanded":true,"children":[{"id":"cc4e1e60-de0e-4390-bba1-60c16ad8c5e5","topic":"Find操作 = 最坏树高","expanded":true,"children":[{"id":"06091958-72f5-49ec-898d-5a970e65eb22","topic":"初始版本","expanded":true,"style":{"background":"#EEEEEE"},"formula":{"tex":"O(n)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(n)</annotation></semantics></math></span>"}},{"id":"ede64f40-9972-40cc-90cc-3f9470859a64","topic":"Union优化后","expanded":true,"style":{"background":"#EEEEEE","borderColor":"#FFAD36"},"formula":{"tex":"O(\\log_2 n)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mi>n</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(\\log_2 n)</annotation></semantics></math></span>"}},{"id":"8b2b8428-e0d3-4324-b4fb-97ee24cad082","topic":"Find优化后","expanded":true,"style":{"background":"#EEEEEE","borderColor":"#FFAD36"},"formula":{"tex":"O(\\alpha(n))","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><mi>α</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(\\alpha(n))</annotation></semantics></math></span>"}}]},{"id":"b44ee75a-6b03-4bd3-a6b2-1979916fff3c","topic":"将n个独立元素经过\nUnion合并为一个集合","expanded":true,"children":[{"id":"e0d165d8-9466-498e-96b1-ca7c776540f5","topic":"初始版本","expanded":true,"style":{"background":"#EEEEEE"},"formula":{"tex":"O(n^2)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><msup><mi>n</mi><mn>2</mn></msup><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(n^2)</annotation></semantics></math></span>"}},{"id":"5eaea13c-6a54-41af-a3f1-93436a910cee","topic":"Union优化后","expanded":true,"style":{"background":"#EEEEEE","borderColor":"#FFAD36"},"formula":{"tex":"O(n\\log_2 n)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><mi>n</mi><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mi>n</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(n\\log_2 n)</annotation></semantics></math></span>"}},{"id":"4cbcd647-2ed1-4f22-9522-26d60a96d838","topic":"Find优化后","expanded":true,"style":{"background":"#EEEEEE","borderColor":"#FFAD36"},"formula":{"tex":"O(n\\alpha(n))","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mi>α</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(n\\alpha(n))</annotation></semantics></math></span>"}}]}]}]}]},{"id":"d03e8b46-d0f8-442b-80d6-528e8ea04b51","topic":"应用：","expanded":true,"children":[{"id":"b0c8d946-64ca-4d00-be15-480ef9130d55","topic":"判断图的连通分量","expanded":true},{"id":"811b4517-89dc-4dd3-9122-deead98b033e","topic":"判断图是否有环","expanded":true},{"id":"62cb439e-5b70-40a5-88f2-0d62514b9f34","topic":"Kruskal算法","expanded":true}]},{"id":"af64d4eb-87be-41e3-9579-8a293b26ad62","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6e0f4c93-3ccf-43f7-bc7c-8628a89156b3","topic":"新考点，没考过","expanded":true}]}]},{"id":"b1ae1f67-e129-43db-83a1-2a6af7e8e154","topic":"END","expanded":true}]},"summaries":[{"id":"030e7744-a7c8-4381-972c-038d939067c9","parentId":"85a931fe5a0aeba77d77e9f7c1","start":1,"end":2,"label":"0还是1 ---> 看题目"},{"id":"79089f5e778bbf0e58c22a413a","parentId":"e8a8f007b4d91c7af642cab42a","start":0,"end":0,"label":"默认谈的就是有序树"},{"id":"930b03e2899944d2820ffbaf7e","parentId":"d56ae45541e9f68d2c4449313b","start":1,"end":1,"label":"访问l/rchild后设置他们的tag和child，以及设置自己的tag和child"},{"id":"69eb40ecbd68cd73c381f892d4","parentId":"5f599383fd4b0efb04554af2d0","start":4,"end":4,"label":"代码实现：先把森林改为孩子兄弟表示法，然后先序 or 中序遍历即可"},{"id":"bc88883a-60b1-4d6a-83f7-7ad2ada8c965","parentId":"51ca2526-9caf-423f-b0ab-7d55d22b6368","start":0,"end":2,"label":""},{"id":"0233540b-92ca-48dc-ad5e-0428db114513","parentId":"5b9b97bfe0ab07674deabaa703","start":5,"end":5,"label":"详见图那章"}],"boundaries":[{"id":"5f088e4d1d3b65d2b9ae680a26","parentId":"ecf97e0d6418ab080b0bdb3f79","start":0,"end":0,"label":"概念不能忘了"},{"id":"6a49027a8b0aa6a184b4593467","parentId":"0299923c4b6b29cea75ae87d28","start":1,"end":1,"label":"故需要堆栈的支持"}]}}},{"id":"a169c6e0-21d5-4942-845c-a10df717aac5","topic":"第六章 图","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/data-structures/ds-00-sheet5","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"ds-00-sheet5","title":"第六章 图","structure":"timeline-h","theme":"auto","root":{"id":"a2bb705901eb35d8cb04493407","topic":"第六章 图","expanded":false,"children":[{"id":"ff7aa9a13ee832ccb7c18819c3","topic":"图的定义","expanded":true,"children":[{"id":"0d4bb47ec79bf9e6fbaf0bbbda","topic":"序偶ordered pair","expanded":true,"children":[{"id":"31f8258396d9fff63b74c8e017","topic":"有序偶：有序边","expanded":true,"children":[{"id":"b3e90f26639b94168638d8d91f","topic":"就是有两个点AB，的<A, B>","expanded":true}]},{"id":"958bc2450268ea3d68d2f962cd","topic":"无序偶：无序边","expanded":true,"children":[{"id":"799b137dc708c7f0cc9c397e50","topic":"两个点AB，的(A, B)","expanded":true}]}]},{"id":"1d7b5dc229fb266116ce49b99a","topic":"各种各样的图","expanded":true,"children":[{"id":"899dd2d4-cf61-4695-8612-4be6c3861909","topic":"表示","expanded":true,"children":[{"id":"c222470f-af59-4caf-a33a-17bdf3649589","topic":"","expanded":true,"children":[{"id":"35a53e7d-0629-4a7b-8fd4-e5a2dd3383fe","topic":"有向边","expanded":true,"children":[{"id":"9a54f388-e30a-4395-abcd-791a9fec16b1","topic":"","expanded":true,"formula":{"tex":"E = \\{<1, 2>, <2, 3>\\}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>E</mi><mo>=</mo><mo stretchy=\"false\">{</mo><mo>&lt;</mo><mn>1</mn><mo separator=\"true\">,</mo><mn>2</mn><mo>&gt;</mo><mo separator=\"true\">,</mo><mo>&lt;</mo><mn>2</mn><mo separator=\"true\">,</mo><mn>3</mn><mo>&gt;</mo><mo stretchy=\"false\">}</mo></mrow><annotation encoding=\"application/x-tex\">E = \\{&lt;1, 2&gt;, &lt;2, 3&gt;\\}</annotation></semantics></math></span>"}}]},{"id":"026a55c0-43c6-43e6-a7c5-26e0cc52fcec","topic":"无向边","expanded":true,"children":[{"id":"b07cc3fa-d17d-4388-aaf5-79069f1c8a2b","topic":"","expanded":true,"formula":{"tex":"E = \\{(1, 2), (2, 4)\\}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>E</mi><mo>=</mo><mo stretchy=\"false\">{</mo><mo stretchy=\"false\">(</mo><mn>1</mn><mo separator=\"true\">,</mo><mn>2</mn><mo stretchy=\"false\">)</mo><mo separator=\"true\">,</mo><mo stretchy=\"false\">(</mo><mn>2</mn><mo separator=\"true\">,</mo><mn>4</mn><mo stretchy=\"false\">)</mo><mo stretchy=\"false\">}</mo></mrow><annotation encoding=\"application/x-tex\">E = \\{(1, 2), (2, 4)\\}</annotation></semantics></math></span>"}}]}],"formula":{"tex":"G = (V, E)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>G</mi><mo>=</mo><mo stretchy=\"false\">(</mo><mi>V</mi><mo separator=\"true\">,</mo><mi>E</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">G = (V, E)</annotation></semantics></math></span>"}}]},{"id":"d659f07d91487254356dbb0bec","topic":"有向图","expanded":true,"children":[{"id":"22ba027836e98871a38ab8c956","topic":"无向图","expanded":true,"children":[{"id":"5688d2db860aa8be1a831abe97","topic":"简单图","expanded":true,"children":[{"id":"4678fedab77b150e7027ab2cde","topic":"完全图","expanded":true,"children":[{"id":"c73b4fbb05dbb6360abed95607","topic":"子图","expanded":true,"children":[{"id":"940ad75c64daa301c889fa0c3d","topic":"入度、出度","expanded":true}]}]}]}]}]},{"id":"fabb26c469f883d3173ef929ad","topic":"简单图：","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-95f91ea306edc4.png","width":323,"height":259},"children":[{"id":"f3b968737f986d65a7ee0bf8be","topic":"不存在顶点到其自身的边，且同一条边不重复出现","expanded":true},{"id":"150226d0-5415-43d0-9382-4cdbb5705c75","topic":"举例：有向图第一个是。无向图第一个是。","expanded":true}]},{"id":"3a18156fb2c9163308b3489fe7","topic":"完全图（简单完全图）：每两个顶点都可以路径为一的方式互通","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-70620841f9ee27.png","width":234,"height":128},"children":[{"id":"277a5ea0289be38440d8b8a153","topic":"无向图","expanded":true,"formula":{"tex":"n \\text{ 个顶点，有 } C_n^2 = \\frac{n(n-1)}{2} \\text{ 条边}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>n</mi><mtext> 个顶点，有 </mtext><msubsup><mi>C</mi><mi>n</mi><mn>2</mn></msubsup><mo>=</mo><mfrac><mrow><mi>n</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo>−</mo><mn>1</mn><mo stretchy=\"false\">)</mo></mrow><mn>2</mn></mfrac><mtext> 条边</mtext></mrow><annotation encoding=\"application/x-tex\">n \\text{ 个顶点，有 } C_n^2 = \\frac{n(n-1)}{2} \\text{ 条边}</annotation></semantics></math></span>"}},{"id":"d8e474d4-3a1c-47b2-97cc-6b38feb825ca","topic":"有向图","expanded":true,"formula":{"tex":"n \\text{ 个顶点，有 } 2 * C_n^2 = n(n-1) \\text{ 条边}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>n</mi><mtext> 个顶点，有 </mtext><mn>2</mn><mo>∗</mo><msubsup><mi>C</mi><mi>n</mi><mn>2</mn></msubsup><mo>=</mo><mi>n</mi><mo stretchy=\"false\">(</mo><mi>n</mi><mo>−</mo><mn>1</mn><mo stretchy=\"false\">)</mo><mtext> 条边</mtext></mrow><annotation encoding=\"application/x-tex\">n \\text{ 个顶点，有 } 2 * C_n^2 = n(n-1) \\text{ 条边}</annotation></semantics></math></span>"}}]},{"id":"4e683830bc69f84d53a0abad7e","topic":"子图：","expanded":true,"children":[{"id":"d37983a966c8877794790ad3f1","topic":"从图开始，可以删点和边形成新的图（但是需要保证子图一定是图，至少有一个顶点）","expanded":true,"children":[{"id":"50ea55646788290a305ffac9e9","topic":"但是注意如果E‘中有<A, B>，而V'中且没有A或B节点的话，就说明不是子图（就是一条边，有一边的顶点消失了）","expanded":true},{"id":"02fc149b-0565-4517-bba7-97598bacb226","topic":"关于空图、空树、空表：","expanded":true,"children":[{"id":"0311820f-2ef2-47d5-a559-102617062187","topic":"空表（线性表中没有元素），空树（没有结点），空图（也称为无边图，没有边，有节点）。","expanded":true},{"id":"a3ac29d5-6634-4adc-aadb-b1eab5826212","topic":"图中不能一个顶点也没有，图的顶点集V一定非空，但是边集E可以为空，此时图中只有顶点而没有边。","expanded":true}]}],"formula":{"tex":"\\text{图为 } G = (V, E)\\text{，子图为 } G' = (V', E')\\text{，其中 } V' \\subseteq V, E' \\subseteq E\\text{。}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mtext>图为 </mtext><mi>G</mi><mo>=</mo><mo stretchy=\"false\">(</mo><mi>V</mi><mo separator=\"true\">,</mo><mi>E</mi><mo stretchy=\"false\">)</mo><mtext>，子图为 </mtext><msup><mi>G</mi><mo mathvariant=\"normal\" lspace=\"0em\" rspace=\"0em\">′</mo></msup><mo>=</mo><mo stretchy=\"false\">(</mo><msup><mi>V</mi><mo mathvariant=\"normal\" lspace=\"0em\" rspace=\"0em\">′</mo></msup><mo separator=\"true\">,</mo><msup><mi>E</mi><mo mathvariant=\"normal\" lspace=\"0em\" rspace=\"0em\">′</mo></msup><mo stretchy=\"false\">)</mo><mtext>，其中 </mtext><msup><mi>V</mi><mo mathvariant=\"normal\" lspace=\"0em\" rspace=\"0em\">′</mo></msup><mo>⊆</mo><mi>V</mi><mo separator=\"true\">,</mo><msup><mi>E</mi><mo mathvariant=\"normal\" lspace=\"0em\" rspace=\"0em\">′</mo></msup><mo>⊆</mo><mi>E</mi><mtext>。</mtext></mrow><annotation encoding=\"application/x-tex\">\\text{图为 } G = (V, E)\\text{，子图为 } G&#x27; = (V&#x27;, E&#x27;)\\text{，其中 } V&#x27; \\subseteq V, E&#x27; \\subseteq E\\text{。}</annotation></semantics></math></span>"}}]},{"id":"df2ba279a1188faf0df4b8e1ac","topic":"真子图","expanded":true,"children":[{"id":"e009f76422989c68fda2d80332","topic":"同’子图‘，不允许什么都不删","expanded":true}]},{"id":"d9ab11deadc9a13d84f41afd25","topic":"生成子图","expanded":true,"children":[{"id":"54696b2f71baaf003d9fe8264f","topic":"同’子图‘，但是只允许删除边","expanded":true}]},{"id":"2318a80fa3a8dd3cb28fab6c5c","topic":"极小连通子图","expanded":true,"style":{"background":"#F8F7F7"},"children":[{"id":"5fb9451c7e993e3888ef4b5baa","topic":"满足连通的情况下没有多余的边","expanded":true,"style":{"background":"#F8F7F7"}}]}]},{"id":"10ba578e900a3d299ac499f7de","topic":"顶点的度","expanded":true,"children":[{"id":"179b36bc0939b0ec4e287b1788","topic":"有向图","expanded":true,"children":[{"id":"d5db4719e73aa7cce00ccbde03","topic":"顶点的入度和出度之和","expanded":true}]},{"id":"dd7ab4cb007bab0632938b926b","topic":"无向图","expanded":true,"children":[{"id":"321ba8e3fe184e6585bde96ea8","topic":"该顶点相连的边的个数","expanded":true}]}]},{"id":"ef39a9048d7ae8a7d965093337","topic":"简单路径","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"adeb511ace2808b5c097ca6857","topic":"顶点不重复的路径","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"38685a2cf2597a6091fc48af32","topic":"简单回路","expanded":true,"children":[{"id":"6e6b13afbc5a6a59057c9b46b3","topic":"顶点不重复的回路","expanded":true}]}]}]},{"id":"086aff43913a26f5794608e54a","topic":"无向图","expanded":true,"children":[{"id":"a9fa88aac51ae3e1353f4bb2f8","topic":"连通图","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"f248c3e0ad7805fd7569b9bb11","topic":"图中任意两个顶点之间都有路径可达","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"6fd029e9-8be9-4e79-b037-85efec0cfa37","topic":"连通子图","expanded":true,"children":[{"id":"19f32d80-131f-40d4-8553-802bf2415370","topic":"若图的子图是连通图，则称为连通子图","expanded":true}]},{"id":"20f17465-f876-4118-83bd-0a4866ba075a","topic":"极大连通子图","expanded":true,"children":[{"id":"ae8d898f-ab77-46d4-bdd1-7efbc2ad1efc","topic":"极大连通子图是该图中所有连通子图中边数最多的子图","expanded":true},{"id":"e8360b38-3b86-4896-88b1-710f9cd53c59","topic":"连通图的极大连通子图是它本身","expanded":true}]},{"id":"ae9b5376ad797c17fca639ebf5","topic":"连通分量","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"373afe0d224b63be280e0a4c94","topic":"也就是极大连通子图","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"85d9f8c00d5898cbb9eb594209","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f9d37a526823cb.png","width":402,"height":159}}]}]}]},{"id":"f4c96ebe-367c-4663-8e3d-85b1ac3d2126","topic":"极大、极小连通子图的关系","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"e839c993-af03-4ecd-b1eb-224e7e43ec82","topic":"无向图+连通+极大连通子图","expanded":true,"children":[{"id":"3130a0ad-9745-4811-90fc-31536e7dfe6e","topic":"自己","expanded":true}]},{"id":"ceb651c4-0157-41a6-a0b7-0685b789d2b2","topic":"无向图+连通+极小连通子图","expanded":true,"children":[{"id":"5412503f-ca2b-40b6-bc7d-3d7c783f5a5d","topic":"自己的生成树","expanded":true}]},{"id":"cf678356-b389-44f5-b805-c542578ceecb","topic":"无向图+不连通+极大连通子图","expanded":true,"children":[{"id":"9adf4c65-13a3-4cd0-8d84-cadb50e6a59d","topic":"有多个，不需要删除点、边","expanded":true}]},{"id":"29ed5d69-3570-4a97-9b25-83887ea1e86c","topic":"无向图+不连通+极小连通子图","expanded":true,"style":{"background":"#F8F7F7"},"children":[{"id":"77d29389-b987-4792-9599-da2f01c3a58f","topic":"上面多个极大连通子图各自的生成树","expanded":true}]}]},{"id":"93ebfde13d09cdd0c0ea48ac13","topic":"有向图","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c548bab48fa8ee20dec6a883d2","topic":"（强）连通图","expanded":true,"style":{"background":"#F8F7F7"},"children":[{"id":"40e9d566b9ca79a45b08a93bb2","topic":"图中任意两个顶点之间都有路径可达","expanded":true,"style":{"background":"#F8F7F7"}}]},{"id":"f2b90f5f3c5a4860388b982c1f","topic":"（强）连通分量","expanded":true,"style":{"background":"#F8F7F7"},"children":[{"id":"062819328518a43db3d448e5e1","topic":"图中的极大连通子图","expanded":true,"style":{"background":"#F8F7F7"}}]}]},{"id":"f7dac218272871cba1d63a83ca","topic":"无向图连通辨析：","expanded":true,"children":[{"id":"99fe6f7c-5d03-4150-a1f3-dd3aaf23deff","topic":"无向图中：","expanded":true,"children":[{"id":"25160617-b8c1-4804-8203-f3d463dbdbfb","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a5c04c918a5410.png","width":284,"height":195},"children":[{"id":"4219ae06-748b-4d37-8785-d07f621872f5","topic":"连通图的子图中有部分是不连通的","expanded":true},{"id":"a8e43ded-1cab-43a8-b9d8-8b09d6bd895e","topic":"极大和极小连通子图是两个概念","expanded":true},{"id":"d5b7b863-06a6-4e1c-98d3-2c0e566b0b29","topic":"在无向连通图中，极小连通子图 = 生成树","expanded":true,"children":[{"id":"2204d897-c57e-4347-8e6b-fd09839a6c21","topic":"如果是无向不连通图，则没有生成树","expanded":true}]},{"id":"9df2e8ce-c973-4594-bcb4-ccce244ff69a","topic":"无向图中，连通分量 = 极大连通子图","expanded":true}]}]},{"id":"8e597183089b449ea674e95a14","topic":"原始图：","expanded":true,"children":[{"id":"dc302c54-de20-4e6e-99bc-1ff579b90f0b","topic":"原本的图","expanded":true}]},{"id":"12d9daa62da986ea203488123b","topic":"子图：","expanded":true,"children":[{"id":"41d940308618cb55def7d8b599","topic":"含有该图中部分边和结点的图，一定是能够形成一个图的“边和结点”集合","expanded":true}]},{"id":"7ab85129215a9bff7bba1a9afa","topic":"连通分量：","expanded":true,"children":[{"id":"6bfa7f8ede6babcbcee21876be","topic":"首先其是子图，就是在该子图的结点对中有所有原始图中的结点对的边，全都要","expanded":true}]},{"id":"a6ca31a1ccd97bb70af709b12e","topic":"生成树：","expanded":true,"children":[{"id":"4f9a949682ebc7a573a2293bbd","topic":"极小连通子图，一定不成环","expanded":true}]},{"id":"3ec8dc6e0a5adbd2bc41d8f56d","topic":"连通分量、生成树的核心区别点","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"13fad6668e5b0a6b2c3949eef5","topic":"【连通分量】是一定要所有的边都在的，连通分量的概念是图论中为了说明【有多少个】连通分量而存在的","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"963910ad7d08cee00e24681eaf","topic":"故题中问要求某一个连通分量，只需要求【其中存在的顶点】即可，可以不说明边（建议也说了）","expanded":true,"style":{"background":"#FFABD5"}},{"id":"4bc9826002ca85062febc856f1","topic":"题中一般考察的是一共有【多少个】连通分量，而不会让你用算法【打印出】连通分量","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"9b381ba8fc69f004689f8b7f4f","topic":"【生成树】一个子图的生成树一定是无环的","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"d8890480-9823-4386-a87a-472a08fd5616","topic":"生成树一般都不是连通分量（除非原图本来就是一个树）","expanded":true},{"id":"76f8626d-7d75-4c45-b89e-df15f93f42a3","topic":"题目会让你【求】生成树","expanded":true}]},{"id":"7df7077c-5293-49e2-b7de-a1bd77d74516","topic":"故：\nDFS、BFS可以找连通分量✅\nDFS、BFS的结果（生成树）是连通分量❌","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a9a0ac31-2679-4e46-977d-64b50785ca56","topic":"DFS、BFS的生成树的个数 = 连通分量的个数。通过改进可以打印出连通分量（了解）","expanded":true}]}]}]},{"id":"8009b9fba3a986beb340bb221b","topic":"有向图：","expanded":true,"children":[{"id":"2dc69a8a-522f-4d72-bf03-87f629b846da","topic":"一个例子","expanded":true,"children":[{"id":"644a5c9fb91829968cb8b9f4ed","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2697de0315092a.png","width":424,"height":76},"children":[{"id":"739b0492abbb2a962d94eaaf3c","topic":"题干 = 一个有向图存在有环的子图","expanded":true}]},{"id":"b57aa105776aec91acb34b7f0a","topic":"A. 与有无根无关","expanded":true,"children":[{"id":"af448ba8-2fbc-43a6-8a38-c8a70619a5f3","topic":"（从一个结点出发可以抵达所有其他结点）","expanded":true}]},{"id":"0b7b94e0f78bc0c5fcda7979e7","topic":"B. 强连通图","expanded":true,"children":[{"id":"de5bc269dbaadb3a344378b4ea","topic":"强连通图：每对顶点都可以互通，所以起码整个图都得是有环图才行，而现在只是其中部分有环而已","expanded":true,"children":[{"id":"b8c8f08f-fcaa-444a-a75f-3827cfb692f2","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-07ac0b90da8969.png","width":151,"height":96}}]}]},{"id":"88f9d7a31bb88db0952c6b4a26","topic":"C. 含有多个入度为0的顶点","expanded":true,"children":[{"id":"1fbbfb2bb5fb96c42c65c9d12f","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-6401884862e26b.png","width":115,"height":80}}]},{"id":"8b6b5027af1b8f735f49f8aa2a","topic":"D. 顶点数大于1的强连通分量","expanded":true,"children":[{"id":"aa69c2736bcbc1caedd93a1596","topic":"D选项 = 有一个顶点数超过1的子图是环","expanded":true}]}]},{"id":"e8fa74b8fe28c0df3d884bfe74","topic":"有向树","expanded":true,"children":[{"id":"561804ece7496a8dd6a5b8393e","topic":"一个顶点的入度为0，其余顶点的入度都是1的有向图","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-312a46666fcaf6.png","width":135,"height":111}}]}]},{"id":"c8fdf925-22dd-4727-beec-5c8b4e207064","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"d01bb475-d8b1-4128-b5f7-c9f05fb8d4d0","topic":"09、10、11、13、17、22","expanded":true}]}]},{"id":"0b28090cf1cab0ec111f9bb83c","topic":"图的存储结构","expanded":true,"children":[{"id":"96d11416-81bd-4368-8ef7-eb4719af1c0d","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a143ebb2-0459-488c-b8ef-7a48c732dcf6","topic":"15大、21大","expanded":true}]},{"id":"8fbb56a5372b92530702686426","topic":"邻接矩阵（二维矩阵存储）","expanded":true,"children":[{"id":"07f81c36d5abfe7add1648a504","topic":"稠密图","expanded":true,"children":[{"id":"3095fe25-572b-4a15-8ddb-5aa466b96701","topic":"开辟整个矩阵的空间","expanded":true}]},{"id":"0438b9fd5e4bd1331981188eb8","topic":"找顶点的入度出度要遍历行/列，要O(n)","expanded":true},{"id":"151bc8c706a93f6c9f71ca4c7a","topic":"可以非常快速的定位到两个顶点的边关系","expanded":true},{"id":"f37bdd02204b43f70bb1fa9c16","topic":"取值","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"96b2f47c-efc3-4dc3-82ed-570490a9c721","topic":"无向图","expanded":true,"children":[{"id":"7f584def85c8fe7d58d3da71ec","topic":"0","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"1d6a68b3b9fb24f83f0eb85c5a","topic":"A[i][j] = A[j][i] = 0，则说明不存在 i 到 j 的边","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"55848922-8080-4056-a883-25e5606a80de","topic":"1","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"c75496cd-bb7a-4d86-b32b-fe46c8bfba78","topic":"A[i][j] = A[j][i] = 1，则说明存在 i 到 j 的边","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"cac1abaa-70e5-4589-80a7-975e59f81227","topic":"有向图","expanded":true,"children":[{"id":"1708811c-71c6-45ca-9ecf-a7550242d14b","topic":"n","expanded":true,"children":[{"id":"d20e4c26-d3a6-41ef-8e3a-b3946ea41100","topic":"A[i][j] = n，则说明从 i 到 j 的边权重为n","expanded":true}]},{"id":"b3f8c75b48db9d5125bc29824c","topic":"0/-1/无穷","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"447b263afb4bbce7c1700b4fbc","topic":"对角线（自己到自己）、不存在的边","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"8d1b6d1f-2abc-4271-b261-c54045cf3dd2","topic":"性质：","expanded":true,"children":[{"id":"513b01ce-cad6-4639-9904-4a10fce81918","topic":"无向图：对称矩阵","expanded":true}]}]},{"id":"6f1b0646b3cb3d91b4459ab100","topic":"邻接表（数组+链表）","expanded":true,"children":[{"id":"b7e881f2423a6c9354b198bede","topic":"稀疏图","expanded":true},{"id":"e279584b1eaa0b733279baa11a","topic":"需要大量计算入度最好用【逆邻接表】","expanded":true}]},{"id":"c0e8e09290ebc8d0aed1dada6a","topic":"十字链表（有向）","expanded":true,"children":[{"id":"a039038d-36b3-4e32-8f0f-57f17cfb2f5c","topic":"对邻接表的优化：又想要入度又想要出度","expanded":true,"children":[{"id":"45d9794a2db9a74cc3585a8a69","topic":"顶点结点","expanded":true,"children":[{"id":"4a0b434429a953c4aef6184752","topic":"<data, in, out>","expanded":true}]},{"id":"71fa069cfc29ed11096c0a2f7b","topic":"弧结点","expanded":true,"children":[{"id":"c79bf9afe7b9933e8ad159776b","topic":"<尾, 头, 同头, 同尾>","expanded":true}]}]},{"id":"25985a1d-6d8c-4153-a074-a8161bf93202","topic":"画图三步走：","expanded":true,"children":[{"id":"23bae545-aa70-402a-bb06-e1e60bc2bd5d","topic":"1. 画邻接表","expanded":true,"children":[{"id":"01c85a7b-a327-4b7a-b5e5-9c8364a774f3","topic":"考题注意顶点序号从0还是从1开始","expanded":true}]},{"id":"22514444-e70c-4d7e-bc39-d1e71079d8b7","topic":"2. 增加弧结点的域","expanded":true},{"id":"1c849a56-2d2f-4a9a-b676-dab31c05a198","topic":"3. 自己指向自己","expanded":true}]},{"id":"e8d93c80ffab8587758a697bfc","topic":"如何画图：","expanded":true,"hyperlink":"https://www.bilibili.com/video/BV1hV411t7SC?from=search&seid=4785318972996389561&spm_id_from=333.337.0.0","image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a09e86457f10c8.png","width":537,"height":247}}]},{"id":"c4985f3050c8692d1521e8defa","topic":"多重链表（无向）","expanded":true,"children":[{"id":"eac889b8-c984-432e-a8e9-da71feb67b21","topic":"目的：删除边的时候比较麻烦（要搜两个节点），因此我们就把两个节点合二为一","expanded":true},{"id":"017bb802db29de0f66a4493eb8","topic":"先画好点和边，然后找到相同的字母接起来","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-d65beb353a7356.png","width":379,"height":165},"children":[{"id":"9fd85a412fcae498edc028a4d6","topic":"注意：边中存的应该是结点序号，例如a-0，b-1，此处也提个醒","expanded":true}]}]}]},{"id":"c2d8e84ba30998ce437ffaa670","topic":"图的遍历","expanded":true,"children":[{"id":"82299eee52082f9c8f3b38180d","topic":"BFS","expanded":true,"children":[{"id":"48185450f2aa378a7e77baef61","topic":"队列","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"4b59f579d56b902796c10be8f6","topic":"邻接表 O(v + e)","expanded":true,"style":{"background":"#FDD834"}},{"id":"a7bbd484148bbad6def8e91496","topic":"邻接矩阵 O(v^2)","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"d949835af27885dc68c75a2e2e","topic":"广度优先生成树","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a25a5b68625a4cc0e07cbbac28","topic":"只针对无权图进行BFS即可得到最小生成树","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c94bdb8fdd28d4b79e8df8df84","topic":"时间复杂度：O(v^2)/O(v+e)","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"0d7a99fa-fee8-44ad-9a4a-d9d36b934ddd","topic":"要求掌握代码（队列实现）","expanded":true,"children":[{"id":"94a58368-35ed-4527-b44b-36e4a2f3952e","topic":"BFS_MIN_Distance","expanded":true,"code":{"lang":"cpp","code":"void BFS_MIN_Distance(Graph G, int u) {\n    // d[i] 表示从u到i结点的最短路径\n    for(int i = 0; i < G.vexnum; ++i)\n        d[i] = ∞ ;\n    visited[u] = TRUE;\n    d[u] = 0;\n    EnQueue(Q, u); // Q 是BFS队列，Q.push(u)\n    while(!isEmpty(Q)) {    // 如果还有队列\n        DeQueue(Q, u); // 出队，u = Q.pull()\n        for(w = FirstNeighbor(G,u); w >= 0; w = NextNeighbor(G,u,w))\n            // 遍历取出的队列的元素的邻接顶点\n            if(!visited[w]) { // 如果w为u尚未访问的节点\n                visited[w] = TRUE; // 添加访问标记\n                d[w] = d[u] + 1; // 路径长度 + 1\n                EnQueue(Q,w); // 入队，Q.push(w)\n            }\n    }\n}","title":"BFS_MIN_Distance","tokens":[[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"BFS_MIN_Distance","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"Graph","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"G","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"u","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    // d[i] 表示从u到i结点的最短路径","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"G","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"vexnum","darkColor":"#D5C5AA"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"d","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ∞ ","darkColor":"#DEDBD2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"visited","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"u","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"TRUE","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"d","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"u","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"EnQueue","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"Q","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"u","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":" // Q 是BFS队列，Q.push(u)","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"!","darkColor":"#8EA4E2"},{"text":"isEmpty","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"Q","darkColor":"#EEECE6"},{"text":"))","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":"    // 如果还有队列","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"DeQueue","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"Q","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"u","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 出队，u = Q.pull()","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"FirstNeighbor","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"G","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":"u","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"w","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"w","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"NextNeighbor","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"G","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":"u","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":"))","darkColor":"#BAB5A8"}],[{"text":"            // 遍历取出的队列的元素的邻接顶点","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"!","darkColor":"#8EA4E2"},{"text":"visited","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 如果w为u尚未访问的节点","darkColor":"#908B7E"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"visited","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"TRUE","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 添加访问标记","darkColor":"#908B7E"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"d","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"d","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"u","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 路径长度 + 1","darkColor":"#908B7E"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"EnQueue","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"Q","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 入队，Q.push(w)","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}]},{"id":"ec29471e7fc9d41598c8394c58","topic":"DFS","expanded":true,"children":[{"id":"af6a6c3be55b9f7c52241acea1","topic":"递归/堆栈","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"61ea45253f4b9a205bd5085018","topic":"邻接表 O(v + e)","expanded":true,"style":{"background":"#FDD834"}},{"id":"86b955f33838dbfd7c6a2b5a41","topic":"邻接矩阵 O(v^2)","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"093a6ff4bcea6008a7b648bad3","topic":"深度优先生成树","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"0ef991c3521844025fba6ae74d","topic":"只针对无权图进行DFS即可得到最小生成树","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"30ba3bbfded8a79ca99d29640a","topic":"时间复杂度：O(v^2)/O(v+e)","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"1d61c43f-3437-4026-9b67-a2803fd5a994","topic":"要求掌握代码（递归实现）","expanded":true,"children":[{"id":"8e3a117d-2240-4e44-a00b-e90955000e1c","topic":"DFSTraverse & DFS","expanded":true,"code":{"lang":"cpp","code":"bool visited[MAX_VERTEX_NUM]; //访问标记数组\nvoid DFSTraverse (Graph G) { //对图G进行深度优先遍历\n    for(v = 0; v < G.vexnum; ++v)\n        visited[v] = FALSE;    //初始化已访问标记数组\n\n    for(v = 0; v < G.vexnum; ++v) //本代码中是从v=0开始遍历\n        if(!visited[v])\n            DFS(G,v);\n}\n\nvoid DFS(Graph G, int v) { // 从顶点v出发，深度优先遍历图G\n    visit(v);               // 访问顶点v\n    visited[v] = TRUE;      // 设已访问标记\n    for(w = FirstNeighbor(G,v); w >= 0; w = NextNeighbor(G,v,w))\n        if(!visited[w])     // w为v的尚未访问的邻接顶点\n            DFS(G,w);\n}","title":"DFSTraverse & DFS","tokens":[[{"text":"bool","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"visited","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"MAX_VERTEX_NUM","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" //访问标记数组","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"DFSTraverse","darkColor":"#6EC0DF"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"Graph","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"G","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" //对图G进行深度优先遍历","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"v","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"G","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"vexnum","darkColor":"#D5C5AA"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"visited","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"FALSE","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":"    //初始化已访问标记数组","darkColor":"#908B7E"}],[{"text":" "}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"v","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"G","darkColor":"#EEECE6"},{"text":".","darkColor":"#BAB5A8"},{"text":"vexnum","darkColor":"#D5C5AA"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" //本代码中是从v=0开始遍历","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"!","darkColor":"#8EA4E2"},{"text":"visited","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"DFS","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"G","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":" "}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"DFS","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"Graph","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"G","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"v","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 从顶点v出发，深度优先遍历图G","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"visit","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":"               // 访问顶点v","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"visited","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"TRUE","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":"      // 设已访问标记","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"FirstNeighbor","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"G","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"w","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"w","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"NextNeighbor","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"G","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":"v","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":"))","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"!","darkColor":"#8EA4E2"},{"text":"visited","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"},{"text":"     // w为v的尚未访问的邻接顶点","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"DFS","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"G","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":"w","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}]},{"id":"d7bad478-e624-49fd-920e-ee4a725d4d46","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"0377e9b1-e51f-4e47-9f50-0e55ed9f5c39","topic":"13、15、16","expanded":true}]}]},{"id":"f3a8fd288c7aad972e73cac8a5","topic":"图的应用","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"ac9504d5-a9ef-4cdb-98cd-e93a825f930f","topic":"考频：超高","expanded":true,"style":{"background":"#9C27B0"},"children":[{"id":"59021343-6883-4134-ad36-6637e1d21fbb","topic":"10、12*3、13、14、16*2、18、19*2、20*3、21*2、22、09大、11大、14大、17大、18大","expanded":true,"children":[{"id":"7bc8ee32-45e3-4e12-ae71-6902cdeac91d","topic":"大题都是应用题","expanded":true}]}]},{"id":"26bbcd8a78cb259eb09f591e38","topic":"最小生成树算法","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"79c92dc98809703d72895899bd","topic":"无权图：","expanded":true,"children":[{"id":"374abae07b794d5a749d5aebc9","topic":"BFS/DFS都可以找最小生成树","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"60ebe0f3e848086049965ae052","topic":"有权图","expanded":true,"children":[{"id":"e8a884a1c16b9eac52bc6b72d3","topic":"Prim算法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a4582fc8b0b91ad7746ba8cc96","topic":"从头到尾只有一个集合，不断扩大","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-960d694de11935.png","width":337,"height":223},"children":[{"id":"825bb38b21ab8d94e71c596fe6","topic":"时间复杂度","expanded":true,"style":{"background":"#8EDDF9"},"formula":{"tex":"O(V^2)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><msup><mi>V</mi><mn>2</mn></msup><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(V^2)</annotation></semantics></math></span>"}},{"id":"037af337-6cef-441e-974c-f4782fa5cec4","topic":"掌握伪代码：英文代码+每一句话都写注释","expanded":true,"code":{"lang":"plaintext","code":"/**\n* G: 图；T: 生成树，树空；\n*/\nvoid Prim(G, T) {\n    T.V = {w}; // 添加任意一个G的顶点w到T的顶点集V中\n    while((G.V - T.V) != ø) { // 如果此时树中不包含全部的顶点\n        (u,v) = find_min_weight(G);\n        // 定义find_min_weight()作用是找到\n        // 满足是 u ∈ T.V 且 v ∈ (G.V - T.V)，且权值最小的边(u,v)\n        T.E = T.E ∪ {(u,v)}; // 边添加到树的边集E中\n        T.V = T.V ∪ {v}; // 顶点插入到树的顶点集V中\n    }\n}","title":"Prim(G, T)","tokens":[[{"text":"/**"}],[{"text":"* G: 图；T: 生成树，树空；"}],[{"text":"*/"}],[{"text":"void Prim(G, T) {"}],[{"text":"    T.V = {w}; // 添加任意一个G的顶点w到T的顶点集V中"}],[{"text":"    while((G.V - T.V) != ø) { // 如果此时树中不包含全部的顶点"}],[{"text":"        (u,v) = find_min_weight(G);"}],[{"text":"        // 定义find_min_weight()作用是找到"}],[{"text":"        // 满足是 u ∈ T.V 且 v ∈ (G.V - T.V)，且权值最小的边(u,v)"}],[{"text":"        T.E = T.E ∪ {(u,v)}; // 边添加到树的边集E中"}],[{"text":"        T.V = T.V ∪ {v}; // 顶点插入到树的顶点集V中"}],[{"text":"    }"}],[{"text":"}"}]]}}]},{"id":"847defec-6bb4-4d33-ba94-9c162240f986","topic":"Party","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]},{"id":"cc7a983cf60b3e5fde363ae5cf","topic":"Kruskal算法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"c5e91ae3bc9ae6dd57d2aadd91","topic":"每次直接找图中最小边，如果不成环，就加进去","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2d48c17e5a5353.png","width":320,"height":218},"children":[{"id":"eddb80c83018daf5a4be49c49c","topic":"时间复杂度","expanded":true,"style":{"background":"#8EDDF9"},"formula":{"tex":"O(e\\log_2 e)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><mi>e</mi><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mi>e</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(e\\log_2 e)</annotation></semantics></math></span>"}},{"id":"b6d6194f-0237-48bd-9ad0-82d407f4ec85","topic":"掌握伪代码：英文代码+每一句话都写注释","expanded":true,"code":{"lang":"plaintext","code":"/**\n* V: 图的顶点集；T: 生成树；\n*/\nvoid Kruskal(V, T) {\n    T.V = V; // 生成树中顶点就是图的顶点集\n    while(compute_connect(T) > 1) {\n        // 定义compute_connect()作用是找树的连通分量个数\n        // 如果连通分量数 > 1\n        (u, v) = find_min_weight(T);\n        // 定义find_min_weight()作用是找到\n        // 满足是 u, v 顶点在不同连通分量中，且权值最小的边(u,v)\n        T.E = T.E ∪ {(v, u)}; // 插入边集到T的边集中\n    }\n}","title":"Kruskal(V, T)","tokens":[[{"text":"/**"}],[{"text":"* V: 图的顶点集；T: 生成树；"}],[{"text":"*/"}],[{"text":"void Kruskal(V, T) {"}],[{"text":"    T.V = V; // 生成树中顶点就是图的顶点集"}],[{"text":"    while(compute_connect(T) > 1) {"}],[{"text":"        // 定义compute_connect()作用是找树的连通分量个数"}],[{"text":"        // 如果连通分量数 > 1"}],[{"text":"        (u, v) = find_min_weight(T);"}],[{"text":"        // 定义find_min_weight()作用是找到"}],[{"text":"        // 满足是 u, v 顶点在不同连通分量中，且权值最小的边(u,v)"}],[{"text":"        T.E = T.E ∪ {(v, u)}; // 插入边集到T的边集中"}],[{"text":"    }"}],[{"text":"}"}]]}}]}]}]}]},{"id":"54eafd86919b91806cd1da0747","topic":"最短路径算法","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"1749680398ab62772d2d18845c","topic":"无权图：","expanded":true,"children":[{"id":"8f6b5882ee8a34b2398b8b42ea","topic":"BFS可以找最短路径","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"994abddea329dcdf4715195035","topic":"有权图","expanded":true,"children":[{"id":"91c985d990fb2affa41e6b0694","topic":"Dijkstra算法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"2618d50aabd9d0b12733984ec2","topic":"使用final[], path[], dis[]去搜寻最短路径，每次都在dis[]中找到最短的路径。","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-30edd9940f95a0.png","width":363,"height":326},"children":[{"id":"3edb1b29432a1f17d3fd293425","topic":"基于贪心算法","expanded":true,"style":{"background":"#FDD834"}},{"id":"e5eb54e67ef91e23f7c0388090","topic":"可以判断有环图","expanded":true},{"id":"d06a5ab922ebbec845bc698b75","topic":"无法判断带负权值的图 ：算法失效","expanded":true,"style":{"background":"#8EDE99"}},{"id":"b709acd30f8aa46b50c45934fc","topic":"时间复杂度 O(v^2)","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"536b7e6c3c2822d0dda448a257","topic":"找两个点的时间复杂度，所有点仍是O(v^3)","expanded":true}]}]}]},{"id":"d7e9462a2b4a4f93247489a7ab","topic":"Floyd算法","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"f3f9adfb19fa8356596bf881df","topic":"动态规范算法，动态维护一个dis[][]和path[][]，每次更新时都加入一个新的节点作为可使用的中转点。","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ed63fe03582232.png","width":406,"height":386},"children":[{"id":"1cdb8694c22a0140b4ff3b4110","topic":"path[]矩阵的用处","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"00897f8da55b61199a35c81454","topic":"图示","expanded":true,"style":{"background":"#FFABD5"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2f8e0139c5ce7a.png","width":516,"height":266},"children":[{"id":"8a9a805b6e0b7d58817e5a70da","topic":"例如：找V0 到 V4","expanded":true,"children":[{"id":"f12aa798f30a788d77cfe87ec3","topic":"V0 -> V3 -> V4","expanded":true,"style":{"background":"#FDD834"}},{"id":"e3595323e33a43fefcfcc9d48c","topic":"找 V0 到 V3","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"9e795f0e114afb7b6925ebf674","topic":"V0 -> V2 -> V3","expanded":true,"style":{"background":"#FDD834"}},{"id":"0d28870ea25ab77fcacaaa8d03","topic":"找 V0 到 V2","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"41781049cb6829ff2ccd8b43d9","topic":"直达","expanded":true}]},{"id":"2f593571699bec8423bc691c5d","topic":"找 V2 到 V3","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"da1a5a5450d85986ec538b14e2","topic":"V2 -> V1 -> V3","expanded":true,"style":{"background":"#FDD834"}},{"id":"fa4a50704549c42be8d4789c7c","topic":"找V2->V1","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"a9d8147394ea83f81cec0ae0bb","topic":"直达","expanded":true}]},{"id":"c5bb8bced00b686510a7cad829","topic":"找V1->V3","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"6a6a427e0cb93b51ddc6b9d24d","topic":"直达","expanded":true}]}]}]},{"id":"9539425cf719895a543199dd69","topic":"找 V3 到 V4","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"3fab23d6cf299c334dcd4befcd","topic":"直达","expanded":true}]}]}]}]},{"id":"200a2cb7631a52b505a7ea3cbb","topic":"无法判断带负权值的【有环图】","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"99d6f315-1839-467f-9162-3782814b0e4e","topic":"环中有负值","expanded":true}]},{"id":"a5188050083aecff08326872a1","topic":"时间复杂度全部顶点","expanded":true,"style":{"background":"#8EDDF9"},"formula":{"tex":"O(V^3)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><msup><mi>V</mi><mn>3</mn></msup><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(V^3)</annotation></semantics></math></span>"}}]}]}]}]},{"id":"64bb046435bbd37d84802b36e2","topic":"有向无环图\n（DAG)","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"8daad02687a96951d3d9d98f4a","topic":"把算式二叉树简化为有向无环图的形式","expanded":true},{"id":"9eb6432e-c79a-4454-965c-b87687c9e2aa","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-36b4ab599725a3.png","width":450,"height":634}}]},{"id":"60eb1995c69898611525f9dad9","topic":"拓扑排序","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"f70b9ac3105a9656e4d05be71b","topic":"AOV网","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"852b01daa4ab9ac22963b9469e","topic":"算法思路","expanded":true,"children":[{"id":"9a692d447ed98c2242325b8400","topic":"找入度为0的点，打印出来，删掉所有与这个点有关的边，一直到最后无点可删","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a10bd5ac100b210d959e0a9c1a","topic":"时间复杂度：O(v + e)","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"bdf8cf5aab587c67ce567a0a6a","topic":"如果无点可删时，图中仍剩有点，就说明有环","expanded":true}]}]}]},{"id":"cdd8f0a62a8860f60a123b3da2","topic":"逆拓扑排序","expanded":true,"children":[{"id":"97d9ebafeeeb00f1716d9ac464","topic":"同理，可以使用逆向DFS来实现","expanded":true,"children":[{"id":"b4097301f55abb40bada49d612","topic":"https://blog.csdn.net/xza13155/article/details/113923901","expanded":true},{"id":"741a53b2edf900fed494d98c87","topic":"设置一个visited数组，一个nowvisited数组","expanded":true}]}]}]},{"id":"30ca254b30f952d573dddb9bf9","topic":"关键路径","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"36b9bc2a38da699040349a2cf2","topic":"AOE网","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a6ab79dfd0097e60557d9aa783","topic":"节点：事件，边：活动","expanded":true},{"id":"430bc9a780593347fa4e4a41b7","topic":"计算五个量：ve(k), vl(k), e(k), l(k), d(k)","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"d49a63d5bc7aef3b42d9da1b46","topic":"ve(k)：事件的最早发生时间","expanded":true},{"id":"4b28ef28773a9187b016596a45","topic":"vl(k)：事件的不得不发生的时间","expanded":true},{"id":"f38ac81f3998d6dafce669063e","topic":"e(k)：活动的最早发生时间，与箭头尾部ve(k)相同","expanded":true},{"id":"59d9418a614bc9eafc6d2ab191","topic":"l(k)：活动的最晚发生时间，与箭头头部l(k) - weight相同","expanded":true},{"id":"080bdedd76e8a5f309ccc9b056","topic":"d(k) = l(k) - e(k)，如果是0，就说明是关键路径","expanded":true}]},{"id":"8c6b2e8471f82899db75ebe181","topic":"举例","expanded":true,"children":[{"id":"3b5ad5a31ed842cbe9638b1758","topic":"找关键路径ve(i), le(i)","expanded":true,"children":[{"id":"215922387f19f16d3c97a9d5f0","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-03b81c71a557fd.png","width":233,"height":298}}]},{"id":"c04b9f4c697b968725afba2040","topic":"找关键路径的活动的\ne(i), l(i), l(i)-e(i)","expanded":true,"children":[{"id":"bb5d2539-7dea-4c84-b67b-962ecd27b5c6","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4fd4901ee9e022.jpg","width":237,"height":237}}]}]}]}]}]},{"id":"9527430c-6920-4d52-b2a6-2a44fc758d5a","topic":"并查集的应用","expanded":true,"children":[{"id":"e32243d8-b812-4962-980e-0dabdbb91fed","topic":"图的连通分量","expanded":true,"children":[{"id":"e2e83c78-6c1f-46c3-95a7-bc3e90efdafe","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-9f46cc43ba8de2.png","width":632,"height":383}}]},{"id":"083b953b-a4c0-489c-a6fd-509132b8393f","topic":"判断是否有环","expanded":true,"children":[{"id":"bea65302-a8a5-4d02-857c-4a326aae43a2","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ba2d1fae09d732.png","width":635,"height":385}}]},{"id":"c0c912c8-48f7-4512-bb18-eadab8c7aaf2","topic":"Kruskal算法","expanded":true,"children":[{"id":"99bb84ce-322e-4aff-9a46-cc89b1ade729","topic":"Kruskal算法的实现一定需要并查集来判断新的最短路径会不会成环","expanded":true,"children":[{"id":"e224a1ba-4043-49da-9e11-e2fc2a6c4af8","topic":"算法实现","expanded":true,"children":[{"id":"d77a68db-d325-46b7-9530-7517ca40c00e","topic":"把所有的边按权值大小递增排序","expanded":true,"icons":["priority:1"]},{"id":"9b263a62-1b41-41d7-a535-5ac96d34710d","topic":"从小到大，使用Find操作检查是否在同一个集合","expanded":true,"icons":["priority:2"]},{"id":"38ca2eca-44db-4341-940b-e22c0aa5f3ee","topic":"如果不再同一个集合，就用Union把两个集合加入到同一个集合中","expanded":true,"icons":["priority:3"]}]},{"id":"fc169ca7-2c3f-4921-88c3-6b115c050278","topic":"所以时间复杂度为：","expanded":true,"children":[{"id":"3240ac42-cce3-4340-a530-b49db8480e59","topic":"","expanded":true,"children":[{"id":"6d83b34c-cedd-4023-b412-869d3995bc6a","topic":"原因：一共有e条边，执行e轮，并查集Find的时间复杂度为log_2e","expanded":true}],"formula":{"tex":"O(e\\log_2 e)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>O</mi><mo stretchy=\"false\">(</mo><mi>e</mi><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mi>e</mi><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">O(e\\log_2 e)</annotation></semantics></math></span>"}}]}]}]},{"id":"cca23567-90dc-470c-833f-74cf014002c2","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"292efe8d-35c1-49c9-b854-6369482c0876","topic":"无","expanded":true}]}]},{"id":"ca19ef0113188e8ac532a8dfed","topic":"END","expanded":true}]},"summaries":[{"id":"129c07f3-48ee-4a0a-a540-3b4b04763950","parentId":"fabb26c469f883d3173ef929ad","start":0,"end":0,"label":"不满足：多重图/复杂图"},{"id":"bb4b65f419693ac19c97b85ae7","parentId":"1d7b5dc229fb266116ce49b99a","start":6,"end":7,"label":"生成子图 + 极小连通子图 = 生成树"},{"id":"667a6ab9c37b2e5ae5f9884e1d","parentId":"f7dac218272871cba1d63a83ca","start":1,"end":4,"label":""}],"boundaries":[{"id":"4998e125b1c8c7edb7840a9891","parentId":"1d7b5dc229fb266116ce49b99a","start":2,"end":2,"label":"数据结构只研究这一种"},{"id":"604afdf6f069dda6e8f5484928","parentId":"d949835af27885dc68c75a2e2e","start":0,"end":0,"label":"如果给定的是邻接矩阵，则生成树唯一，如果是邻接表，则生成树不唯一"},{"id":"962b2209531b83e8dec57a1e8f","parentId":"093a6ff4bcea6008a7b648bad3","start":0,"end":0,"label":"如果给定的是邻接矩阵，则生成树唯一，如果是邻接表，则生成树不唯一"},{"id":"315945e71809ea93bb562a0995","parentId":"00897f8da55b61199a35c81454","start":0,"end":0,"label":"多层递归，还是比较麻烦"}]}}},{"id":"ad98277b-5823-421f-a71d-6752872e76a3","topic":"第七章 查找","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/data-structures/ds-00-sheet6","expanded":false,"maxHeight":260,"doc":{"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":"直接解决了堆积的问题，不会出现堆积"}]}}},{"id":"692f2d66-bb21-43ea-af69-c6b86064f745","topic":"第八章 排序","expanded":true,"direction":"right","nestedMap":{"src":"kaoyan/408/data-structures/ds-00-sheet7","expanded":false,"maxHeight":260,"doc":{"format":"brushup-mindmap-v1","id":"ds-00-sheet7","title":"第八章 排序","structure":"timeline-h","theme":"auto","root":{"id":"a1bbf1c4bb49baa5ba9eca89a4","topic":"第八章 排序","expanded":false,"children":[{"id":"acf8979bcc9bc67d353ee96c69","topic":"定义","expanded":true,"children":[{"id":"2e1ac0f26d3a5f1805fdbb9cb8","topic":"定义","expanded":true,"children":[{"id":"93690605d8686a3f4c6ba98020","topic":"输入n个记录","expanded":true},{"id":"9f3a44d8abfad5573a6b9a6a1c","topic":"进行算法实现后","expanded":true},{"id":"86cbec9805bb284a9fbaabe994","topic":"输出n个记录","expanded":true}]},{"id":"a47a5836766941401d143963af","topic":"稳定性","expanded":true,"children":[{"id":"07ebe3642a494061a0bfa9e237","topic":"关键字大小相同元素能否做到每次输出后前后位置关系保持不变","expanded":true}]},{"id":"e34871f71ed86b31a6034a0d5e","topic":"排序分类","expanded":true,"children":[{"id":"6369b12b3bab9ac82fbdea94e3","topic":"内部","expanded":true,"children":[{"id":"89881a584a68e70775468beca2","topic":"排序元素全在内存中","expanded":true}]},{"id":"9fea45b5d74b8b95ecca2a967f","topic":"外部","expanded":true,"children":[{"id":"d8bb7c16562b3afb932049ad12","topic":"排序元素需要从外存调入内存","expanded":true}]}]},{"id":"752af6b7fd49bee313fae99f1d","topic":"一个难点","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"55dada2318c8e7d0629e1976a5","topic":"n个关键字基于比较进行排序，问至少要多少次两两比较能够变得有序","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"668ad9b395ea7d1af38c79431b","topic":"有个n个关键字，则这n个关键字的'数组'有 【n!】种形成方式","expanded":true,"style":{"background":"#FFABD5"}},{"id":"a81a70889c2916a0744bbba907","topic":"设至少t次两两比较，则这t次两两比较后数组会有【 2^t 】种结果","expanded":true,"style":{"background":"#FFABD5"}},{"id":"ebf9a29e79688874d65659cfc3","topic":"故形成结果数【一定要 > 】形成方式数","expanded":true,"children":[{"id":"248b9ed1faeb1c2528ace9eeaa","topic":"t 为整数，最后取上整数","expanded":true,"style":{"background":"#FDD834"},"formula":{"tex":"2^t \\ge n! \\text{ 即 } t \\ge \\log_2(n!)","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><msup><mn>2</mn><mi>t</mi></msup><mo>≥</mo><mi>n</mi><mo stretchy=\"false\">!</mo><mtext> 即 </mtext><mi>t</mi><mo>≥</mo><msub><mrow><mi>log</mi><mo>⁡</mo></mrow><mn>2</mn></msub><mo stretchy=\"false\">(</mo><mi>n</mi><mo stretchy=\"false\">!</mo><mo stretchy=\"false\">)</mo></mrow><annotation encoding=\"application/x-tex\">2^t \\ge n! \\text{ 即 } t \\ge \\log_2(n!)</annotation></semantics></math></span>"}}]}]}]},{"id":"b4958259-3925-41ff-9b6b-5498d4d33271","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a652d192-747d-4431-be0f-29763334854d","topic":"无","expanded":true}]}]},{"id":"00b85839bb6b2a730ca9d905fe","topic":"插入排序","expanded":true,"children":[{"id":"c7ace9e2-ac7b-41b1-9071-fd6eea55b26d","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"898cf636-696b-4674-806c-a5e9851089e7","topic":"09、12","expanded":true}]},{"id":"30193c12a1eb0a91679af99783","topic":"排序表","expanded":true,"children":[{"id":"b9f971e81e7b2b9d3ab41bb6d4","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4ef3dcb2406a79.png","width":550,"height":70}}]},{"id":"510a140269aa42f8ec64d9f67c","topic":"代码","expanded":true,"children":[{"id":"f61ac69a8818757532ee2a0de1","topic":"InsertSort 代码实现","expanded":true,"code":{"lang":"cpp","code":"// 1. 插入排序\nvoid InsertSort(ElemType A[], int n) {\n    int i, j;\n    for(i = 2; i < n; i ++){\n        if(A[i] < A[i-1]) { // 如果 i 比前面有序序列的最大元素更小\n            A[0] = A[i]; // 设置哨兵 默认A[0]不存放元素\n            for(j = i-1; A[0] < A[j]; j-- ) { // 从 i-1开始从后往前遍历，\n                // 如果找到比它大的了，或者找到自己在A[0]的哨兵了\n                A[j+1] = A[j]; // 如果更小，往前一位\n            }\n            A[j+1] = A[0];\n        }\n    }\n}","title":"InsertSort","tokens":[[{"text":"// 1. 插入排序","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"InsertSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"2","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++){","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"-","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":"])","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 如果 i 比前面有序序列的最大元素更小","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 设置哨兵 默认A[0]不存放元素","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":"-","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":"--","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 从 i-1开始从后往前遍历，","darkColor":"#908B7E"}],[{"text":"                // 如果找到比它大的了，或者找到自己在A[0]的哨兵了","darkColor":"#908B7E"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 如果更小，往前一位","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"462aa98a16f9b8bc71ad88f068","topic":"示意图","expanded":true,"children":[{"id":"5949ee1adccbaa095a1688e4d4","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b6a4c4c3f99db2.png","width":587,"height":334},"children":[{"id":"42c996d0-06b4-490e-8627-7c429eb7dae4","topic":"边找、边换位置","expanded":true}]}]},{"id":"fc2933ceb24979223ee479f433","topic":"分析&特点","expanded":true,"children":[{"id":"f9080371ec0857eee5ce89611c","topic":"空间复杂度","expanded":true,"children":[{"id":"c728fc7a691b37644a446bdbff","topic":"O(1)","expanded":true}]},{"id":"77ba1eede6295382424b6880a4","topic":"时间复杂度","expanded":true,"children":[{"id":"68fb7b47d2db065fbcf679a801","topic":"最好O(n)","expanded":true},{"id":"f5499e34a108ec943b356ad91b","topic":"平均O(n^2)","expanded":true},{"id":"6b292d10ce08734e9b8f085b31","topic":"最坏O(n^2)","expanded":true}]},{"id":"16c80f456f4b12a4f26938daea","topic":"稳定性","expanded":true,"children":[{"id":"5ddb71790f89a82a3ec1cb1dba","topic":"✅","expanded":true}]},{"id":"46abe53f5eaac18ae33a5bf4a1","topic":"特点：","expanded":true,"children":[{"id":"7899b3fd5e8986599e83f943b5","topic":"可以用于链式存储的排序","expanded":true}]}]}]},{"id":"122b8bd4704acd643e3b6b200f","topic":"折半插入","expanded":true,"children":[{"id":"af193fb2353b3fa6394d0934b5","topic":"思路：","expanded":true,"children":[{"id":"c0d88ff3971aac8d86b6ca6e4e","topic":"对插入排序的改进","expanded":true,"children":[{"id":"3638b56588cafc5df959dae84c","topic":"插入边比较边移动","expanded":true,"children":[{"id":"f25a4373ba8b1c18155839153d","topic":"所以单个元素一次比较和移动的总复杂度为O(n) + O(n)","expanded":true}]}]},{"id":"e71a6257748961d4d2bf49f9ab","topic":"折半插入把移动中的比较和插入分开了","expanded":true,"children":[{"id":"708be9533e699aeabdec3ae230","topic":"比较用二分查找O(logn)，插入就可以直接移动了O(n)","expanded":true}]}]},{"id":"868a094a849822a7047c387c4a","topic":"代码：","expanded":true,"children":[{"id":"f56b4f26e179575f2b593a6a74","topic":"折半插入排序代码实现","expanded":true,"children":[{"id":"f78c4846-3acd-470a-a6af-35122166544b","topic":"找完、再换位置","expanded":true}],"code":{"lang":"cpp","code":"// 2. 折半插入排序\nvoid HaltInsertSort(ElemType A[], int n) {\n    int i, j, low, high, mid;\n    for(i = 2; i < n; i ++) {\n        if(A[i-1] > A[i]) { // 如果 A[i] 比前面有序序列的最大元素更小\n            A[0] = A[i]; // 设置哨兵，就是存要插入的值\n            low = 1, high = i - 1;\n            while(low <= high) { // 就是一个普通的二分查找\n                mid = (low + high)/2;\n                if(A[mid] > A[0]) high = mid - 1;\n                else low = mid + 1;\n            }\n            for(j = i - 1; j >= mid; j --) { // 此处(mid == high+1)，统一向后移动\n                A[j] = A[j-1];\n            }\n            A[mid] = A[0]; // 插入\n        }\n    }\n}","title":"HaltInsertSort","tokens":[[{"text":"// 2. 折半插入排序","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"HaltInsertSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"2","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"-","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 如果 A[i] 比前面有序序列的最大元素更小","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 设置哨兵，就是存要插入的值","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 就是一个普通的二分查找","darkColor":"#908B7E"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":")/","darkColor":"#BAB5A8"},{"text":"2","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"mid","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"])","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"else","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"--)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 此处(mid == high+1)，统一向后移动","darkColor":"#908B7E"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"-","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"mid","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 插入","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"2f38f92c94e8951b891fe9315b","topic":"分析&特点","expanded":true,"children":[{"id":"99c8d9f4de5a4678a5925bbbdb","topic":"空间复杂度","expanded":true,"children":[{"id":"0168794460a8603aa492899333","topic":"O(1)","expanded":true}]},{"id":"c3fadfb06e69d71be89c49b773","topic":"时间复杂度","expanded":true,"children":[{"id":"bd9ab92f82b9c20fceaec91aa8","topic":"最好O(n)","expanded":true},{"id":"88dbead3c5f9e036d1668b725a","topic":"平均O(n^2)","expanded":true,"children":[{"id":"7539d052bf8a83049ad0aad195","topic":"比普通的插入好，折半是O(nlogn)+ O(n^2)","expanded":true}]},{"id":"0b69f8fcda293786db5b795888","topic":"最坏O(n^2)","expanded":true}]},{"id":"324bace31ab869b76727aaf157","topic":"稳定性","expanded":true,"children":[{"id":"0cb84de97e99973e541f7becc2","topic":"✅","expanded":true}]},{"id":"be0bbd8af718eb68c587caaed7","topic":"特点：","expanded":true,"children":[{"id":"8e48b5aa8dc9a2399398d93940","topic":"相比直接插入，不能用于链表了，但是依然稳定","expanded":true}]}]},{"id":"dd56fafc-72e5-4c2d-b2e6-1b5300a1e6be","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"35f2bdcb-8b5b-4f98-bab1-f20228bd84da","topic":"12","expanded":true}]}]},{"id":"6a7923e9923b4957b80a4b6326","topic":"希尔排序","expanded":true,"children":[{"id":"d6c80c7e-b743-46f9-9ab9-213b73a984ca","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"a3e387e4-7931-4b21-a894-47c58904836b","topic":"10、14、15、18","expanded":true}]},{"id":"f62bb754ca2b6d174fe2ca0982","topic":"属于插入排序","expanded":true},{"id":"c1fab12f4ea900f5d673989cc8","topic":"又称：","expanded":true,"children":[{"id":"ceb83f40051adb1ea410a97b95","topic":"缩小增量排序","expanded":true}]},{"id":"11abc75d54fa450315fdb87bd2","topic":"思路：","expanded":true,"children":[{"id":"c9aaf233f389dac57eaadb1097","topic":"将整个数组分割成若干个特殊字表，对各个字表进行直插排序，最后对总表进行一次直插","expanded":true,"children":[{"id":"07f9ef80a39815551b6ccbc043","topic":"优化点：每次进行直插的时候很大概率都会在中间停下，是和【概率/数组情况】有关的","expanded":true}]}]},{"id":"d1ea9f8418fb5dc17da1eb80b8","topic":"示意图：","expanded":true,"children":[{"id":"14abcf4211583f0d6fad99d965","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c59b4c171a8c78.png","width":602,"height":383}}]},{"id":"e11a03a40f99a373e2003bfbaa","topic":"代码：","expanded":true,"children":[{"id":"48d9ef1a57a8f1ad94a1baa343","topic":"ShellSort 代码实现","expanded":true,"code":{"lang":"cpp","code":"// 3. 希尔排序(插入)\nvoid ShellSort(ElemType A[], int n) {\n    // A[0] 不存储元素\n    for(int dk = n/2; dk >= 1; dk = dk/2) // 设置步长，最开始步长为n/2，每次只有两个元素进行排序\n        for(int i = dk+1; i <= n; i ++) // 根据步长进行数组访问\n            if(A[i] < A[i-dk]) { // 进行步长dk的直插排序\n                A[0] = A[i]; // 哨兵\n                for(j = i-dk; j>0&&A[0]<A[j]; j = j-dk) // 进行遍历\n                    A[j+dk] = A[j];\n                A[j+dk] = A[0];\n            }\n}","title":"ShellSort","tokens":[[{"text":"// 3. 希尔排序(插入)","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"ShellSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    // A[0] 不存储元素","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"dk","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":"/","darkColor":"#BAB5A8"},{"text":"2","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"dk","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"dk","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"dk","darkColor":"#EEECE6"},{"text":"/","darkColor":"#BAB5A8"},{"text":"2","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" // 设置步长，最开始步长为n/2，每次只有两个元素进行排序","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"dk","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++)","darkColor":"#BAB5A8"},{"text":" // 根据步长进行数组访问","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"-","darkColor":"#BAB5A8"},{"text":"dk","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 进行步长dk的直插排序","darkColor":"#908B7E"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 哨兵","darkColor":"#908B7E"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":"-","darkColor":"#BAB5A8"},{"text":"dk","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":">","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"&&","darkColor":"#8EA4E2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"]<","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":"-","darkColor":"#BAB5A8"},{"text":"dk","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" // 进行遍历","darkColor":"#908B7E"}],[{"text":"                    ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"dk","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"dk","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"b7484fa76939834958c25aa378","topic":"分析&特点","expanded":true,"children":[{"id":"9529e40fe178a2c198c5391804","topic":"空间复杂度","expanded":true,"children":[{"id":"8d9966678d2b57ca9df4fb3538","topic":"O(1)","expanded":true}]},{"id":"4318cb0da59b6e948c458b7972","topic":"时间复杂度","expanded":true,"children":[{"id":"68b97332e649c7e07c92eb542a","topic":"O(n^1.3)","expanded":true,"children":[{"id":"839a9cdb19ba760ff48eba55a4","topic":"n在某个特定范围内指数为1.3","expanded":true}]}]},{"id":"738a3aea51786973afaf08cbc5","topic":"稳定性","expanded":true,"children":[{"id":"2c4b3994f008d8853c5f39880f","topic":"❎","expanded":true}]},{"id":"d22b1ee0eb4b39c9eff11ab0f6","topic":"特点：","expanded":true,"children":[{"id":"9be8f89c66d92fe2235e7aae35","topic":"only for 顺序表","expanded":true}]}]}]},{"id":"0faa2842b81a0f9ed08af91f4a","topic":"冒泡排序","expanded":true,"children":[{"id":"d8aa6f12e5eadc1ac4f978ae94","topic":"思路：","expanded":true,"children":[{"id":"679941294119a91b3667093196","topic":"像泡泡一样，每次都两两交换把最大/最小交换到对应位置","expanded":true}]},{"id":"482b64edcfea773a19be092fae","topic":"示意图：","expanded":true,"children":[{"id":"bcfa177588080568de27795eaf","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4130b77e9cb0be.png","width":372,"height":361}}]},{"id":"40da7106fc98b18113f3fa5149","topic":"代码：","expanded":true,"children":[{"id":"8a783b915fc98375cdd7c95c89","topic":"BubbleSort 代码实现","expanded":true,"code":{"lang":"cpp","code":"// 4. 冒泡排序\nvoid BubbleSort(ElemType A[], int n) {\n    for(int i = 0; i < n; i ++) { // 进行n次\n        bool flag = false; // 剪枝用\n        for(int j = i; j < n; j ++) { // 递增次序\n            if(A[j] > A[j+1]){\n                swap(A[j], A[j]);\n                flag = true;\n            }\n        } // 完成最后一位的确定\n        if(flag == false) return; // 提前结束\n    }\n}","title":"BubbleSort","tokens":[[{"text":"// 4. 冒泡排序","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"BubbleSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 进行n次","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"bool","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"flag","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"false","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 剪枝用","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 递增次序","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":"]){","darkColor":"#BAB5A8"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"swap","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"]);","darkColor":"#BAB5A8"}],[{"text":"                ","darkColor":"#DEDBD2"},{"text":"flag","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"true","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"},{"text":" // 完成最后一位的确定","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"flag","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"==","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"false","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 提前结束","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"8f5a0aad74eb626f3c78486ba2","topic":"分析&特点","expanded":true,"children":[{"id":"569a454b08b8b4c77695da5485","topic":"空间复杂度","expanded":true,"children":[{"id":"9119258d7c58a35336727a2770","topic":"O(1)","expanded":true}]},{"id":"1a089d0c1659ff9ab55a58d986","topic":"时间复杂度","expanded":true,"children":[{"id":"1ce9d240eadb826ce068883afa","topic":"最好O(n)","expanded":true,"children":[{"id":"934953a31b393a1df281e91c70","topic":"因为有那个剪枝操作","expanded":true}]},{"id":"3ad9f554e06810d55ecaeaa9c9","topic":"平均O(n^2)","expanded":true},{"id":"43f8e7d19028f979a1550a3ffc","topic":"最坏O(n^2)","expanded":true}]},{"id":"d248db402c7af6266a93da63bc","topic":"稳定性","expanded":true,"children":[{"id":"22dbfa852cd97e5b9c27f91a06","topic":"✅","expanded":true}]},{"id":"a5e8121ef10a62d0f4db9969e2","topic":"特点：","expanded":true,"children":[{"id":"634a8753c0a8176e3f88bb611d","topic":"可以用于链表","expanded":true}]}]},{"id":"569e4ee3-5b3e-4eea-a5bb-350351e13358","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"d6a734b7-2a0a-478b-b29c-9d75f59a00a5","topic":"10","expanded":true}]}]},{"id":"456845042cd8f9327ada9be407","topic":"快速排序","expanded":true,"children":[{"id":"c7be2e36-3ee6-4f86-a40f-afcc61c10bb3","topic":"考频：中","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"b9bf70d1-6fc1-4943-af5e-fd785734d79a","topic":"10、14、19、涉及排序的大题","expanded":true}]},{"id":"e65aefb3b8fa84bc78eb69f44f","topic":"思路：","expanded":true,"children":[{"id":"e739f2e23d7b92fd7f2fbaa9f3","topic":"每次快排，选择一个值为pivot，把比其小的放在左边，比其大的放在右边。然后再对pivot左右的数组进行快排","expanded":true,"children":[{"id":"a14811e625bb5eef430a3b98e3","topic":"默认pivot选择最左边的元素","expanded":true}]}]},{"id":"db7bf8eee0fbc891038de9c121","topic":"示意图：","expanded":true,"children":[{"id":"088aa9bc2f28d4d9551c8bad37","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a3f9adc6cabe72.png","width":429,"height":507}}]},{"id":"b05983356cca7258c3f24ac0c2","topic":"代码：","expanded":true,"children":[{"id":"9ae81646bbf9c9ed9740da2597","topic":"QuickSort 代码实现","expanded":true,"code":{"lang":"cpp","code":"// 5. 快速排序\nvoid start(ElemType A[], int n) {\n    QuickSort(A, 1, n); // 把A[0]空出来\n}\nvoid QuickSort(ElemType A[], int low, int high) {\n    if(low > high) return;\n    int mid = Partition(A, low, high); // 进行划分，返回中心点\n    QuickSort(A, low, mid-1); // 对左边\n    QuickSort(A, mid+1, high); // 对右边\n}\nint Partition(ElemType A[], int low, int high) {\n    ElemType pivot = A[low]; // 默认取第一个元素进行搜索\n    // int i, j; // 两个头尾指针 ---- 也可以只用low和high\n    while(low < high) {\n        while(low < high && A[high] >= pivot) high --;\n        A[low] = A[high]; // 因为此时只确定了high比pivot小,所以可以写到左边去\n        while(low < high && A[low] <= pivot) low ++;\n        A[high] = A[low]; // 找到一个比pivot大的左边，就写到右边去\n    }\n    A[low] = pivot; // 中心确定，A[low] or A[high]都可以\n    return low;\n}","title":"QuickSort & Partition","tokens":[[{"text":"// 5. 快速排序","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"start","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"QuickSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 把A[0]空出来","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"QuickSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Partition","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 进行划分，返回中心点","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"QuickSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":"-","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 对左边","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"QuickSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 对右边","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Partition","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"pivot","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 默认取第一个元素进行搜索","darkColor":"#908B7E"}],[{"text":"    // int i, j; // 两个头尾指针 ---- 也可以只用low和high","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"&&","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"high","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":">=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"pivot","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"--;","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"high","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 因为此时只确定了high比pivot小,所以可以写到左边去","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"&&","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"pivot","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++;","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"high","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 找到一个比pivot大的左边，就写到右边去","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"pivot","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 中心确定，A[low] or A[high]都可以","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"return","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"a6fab73a3678121a896d5a7255","topic":"分析&特点","expanded":true,"children":[{"id":"3699c4fe6a685ce1013fc9ef99","topic":"空间复杂度","expanded":true,"children":[{"id":"eeaa5a2089fb9e1a9362285a01","topic":"最好O(log2n)","expanded":true},{"id":"7deb7ed8540bb25005e3eaa164","topic":"平均O(log2n)","expanded":true},{"id":"5328d5cde8c82716153cb9bc7b","topic":"最坏O(n)","expanded":true}]},{"id":"8b885402c048c4a81d759b1a95","topic":"时间复杂度","expanded":true,"children":[{"id":"27faae15fd097fc6e02e78f77f","topic":"最好O(nlog2n)","expanded":true,"children":[{"id":"116a486c62fb0cf77440e9c968","topic":"因为每次都要遍历，所以最好情况就是每次pivot都正好在最中间","expanded":true}]},{"id":"f95a3250bbdb5093d1f8cb78e2","topic":"平均O(nlog2n)","expanded":true,"children":[{"id":"c2d8f2928879563c8bafc87467","topic":"递归调用栈的深度为O(log2n)，每层递归调用都是O(n)的复杂度","expanded":true}]},{"id":"108b95f782b806a7db0eca6bd0","topic":"最坏O(n^2)","expanded":true}]},{"id":"8f390cb7c69a9c404cdc6806ac","topic":"稳定性","expanded":true,"children":[{"id":"6d0934613af8da960460ebb250","topic":"❎","expanded":true}]},{"id":"0cf805caef193b92236faaf4da","topic":"特点：","expanded":true,"children":[{"id":"a7f8f9628ff952237a77db5163","topic":"快排是所有排序中平均性能最佳的排序算法","expanded":true}]}]}]},{"id":"6e680fffc2ba783eab6ffb59c8","topic":"简单选择排序","expanded":true,"children":[{"id":"f8abe53bf45bdcbb2011885acb","topic":"思路：","expanded":true,"children":[{"id":"a8e9b7c96c2a0de053319a92c8","topic":"每次遍历，选择最大or最小的一个元素，放到对应的位置","expanded":true}]},{"id":"a1dbfe3350d84c66ed5d3870c9","topic":"代码：","expanded":true,"children":[{"id":"95c9abeccd6b5b82d4eacab72d","topic":"SelectSort 代码实现","expanded":true,"code":{"lang":"cpp","code":"// 6. 选择排序\nvoid SelectSort(ElemType A[], int n) {\n    int minp = -1;\n    for(int i = 0; i < n; i ++) { // 从前往后找数组中的每一个点\n        minp = i;\n        for(int j = i+1; j < n; j ++) // 查找后面有没有比当前点更小的点\n            if(A[j] < A[minp]) minp = j;\n        swap(A[i], A[minp]); // 进行元素替换\n    }\n}","title":"SelectSort","tokens":[[{"text":"// 6. 选择排序","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"SelectSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"minp","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"-","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 从前往后找数组中的每一个点","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"minp","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++)","darkColor":"#BAB5A8"},{"text":" // 查找后面有没有比当前点更小的点","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"minp","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"minp","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"swap","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"minp","darkColor":"#EEECE6"},{"text":"]);","darkColor":"#BAB5A8"},{"text":" // 进行元素替换","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"4d8aef512f0a59747ab62b5102","topic":"分析&特点","expanded":true,"children":[{"id":"deba8aa2c3589241179dba2a69","topic":"空间复杂度","expanded":true,"children":[{"id":"bb0a559dc11a37b7e560baa7e1","topic":"O(1)","expanded":true}]},{"id":"eaea4e345038e223c72e69bd92","topic":"时间复杂度","expanded":true,"children":[{"id":"6398af9d34e8de5b4ed8eb0d82","topic":"始终是O(n^2)","expanded":true}]},{"id":"067aad79812af5c9be47297d8b","topic":"稳定性","expanded":true,"children":[{"id":"2b7a251a5edb529e626f18d156","topic":"❎","expanded":true}]}]},{"id":"2f69de4b-8e51-45b9-b51a-dcf0c435ea52","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"908091b4-63cc-49d5-8224-a7361a2ac87b","topic":"无","expanded":true}]}]},{"id":"3fc8339b495a088fabd85ba4a6","topic":"堆排序","expanded":true,"children":[{"id":"dde9435e-51fa-45f9-bdb3-7a8c0dee7525","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"4521484e-7615-45bb-a0ed-e57015954227","topic":"09、11、15、18、20、21、22大","expanded":true}]},{"id":"c1d8b8861f88ad044ab4e84746","topic":"思路：","expanded":true,"children":[{"id":"8fe96b62d88b479af2a5d8616f","topic":"把整个数组看做一颗完全二叉树，每个结点的父节点都比其左右孩子的值大/小。","expanded":true,"children":[{"id":"11a93fb074b80d5ac7ee6ac551","topic":"动态的维护这一个完全二叉树","expanded":true},{"id":"062a423ec459ca4f425c2b60c2","topic":"每次找最大/最小就直接取根节点即可","expanded":true}]}]},{"id":"0c01fb4a-e7f1-45bd-a28d-1c24d1749098","topic":"存储方式：","expanded":true,"children":[{"id":"8305be28-d312-4e36-8d11-6e9d6f252e99","topic":"顺序存储，使用完全二叉树的顺序存储结构","expanded":true,"children":[{"id":"83dd0e57-3257-4abb-89f3-ff8e4ec6047a","topic":"让数组从 1 开始","expanded":true}]}]},{"id":"47aa5c049b6bd77b4916e83aa1","topic":"建大根堆：","expanded":true,"children":[{"id":"326951d4968829d36ca53b18e1","topic":"思路：","expanded":true,"children":[{"id":"1cc8a85264ea152b6fbbabd2a3","topic":"从倒数第一个非叶子结点开始，调整其下属的堆，使得自己是这个堆中的最大值","expanded":true}]},{"id":"ca0994ba26c9183626406bb762","topic":"示意图：","expanded":true,"children":[{"id":"815b51c57f1be7848ad99a7c5f","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4125325ccf5b3e.png","width":542,"height":358}}]},{"id":"32bbd8ea1f79a6725b3f68f29e","topic":"代码：","expanded":true,"children":[{"id":"4e999a82253b24af94af9bd31a","topic":"BuildMaxHeap & AdjustHeap","expanded":true,"children":[{"id":"afc9c6b10e58b2c2ebeec8656b","topic":"算法考虑的情况：每个非叶子结点的左右孩子堆都是设置好的大/小顶堆，故需要考虑自己的值非常的小，比左右孩子都还要小，不断的向下移动直到碰到最底部","expanded":true}],"code":{"lang":"cpp","code":"// 7. 堆排序\n// > 建立大顶堆\nvoid BuildMaxHeap(ElemType A[], int len) {\n    // for(int i = (n+1)/2; i >= 0; i --) { // 从 0 开始的数组\n    for(int i = n/2; i > 0; i --) { // 从 1 开始的数组\n        AdjustHeap(A, i, len);\n    }\n}\n// 从 i 点开始进行堆调整\nvoid AdjustHeap(ElemType A[], int p, int len) {\n    A[0] = A[p]; // 把当前值暂存\n    for(int i = 2*p; i <= len, i *= 2) {\n        if( i < len && A[i+1] > A[i]) // 存在右节点，且右边更大\n            i ++; // i移动到较大的A的下标\n        if(A[0] > A[i]) break;\n        else { // A[0] <= A[i]\n            A[i] = A[p]; // 把较大的子节点提到父节点\n            p = p*2; // 修改搜索的节点，整体向下移动\n        }\n    }\n    A[k] = A[0]; // 把最开始的节点放在应该在的位置\n}","title":"BuildMaxHeap & AdjustHeap","tokens":[[{"text":"// 7. 堆排序","darkColor":"#908B7E"}],[{"text":"// > 建立大顶堆","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"BuildMaxHeap","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    // for(int i = (n+1)/2; i >= 0; i --) { // 从 0 开始的数组","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":"/","darkColor":"#BAB5A8"},{"text":"2","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"--)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // 从 1 开始的数组","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"AdjustHeap","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"// 从 i 点开始进行堆调整","darkColor":"#908B7E"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"AdjustHeap","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"p","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"p","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 把当前值暂存","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"2","darkColor":"#E2B159"},{"text":"*","darkColor":"#BAB5A8"},{"text":"p","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"*=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"2","darkColor":"#E2B159"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"&&","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"},{"text":" // 存在右节点，且右边更大","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++;","darkColor":"#BAB5A8"},{"text":" // i移动到较大的A的下标","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"break","darkColor":"#8EA4E2"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"else","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"},{"text":" // A[0] <= A[i]","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"p","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 把较大的子节点提到父节点","darkColor":"#908B7E"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"p","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"p","darkColor":"#EEECE6"},{"text":"*","darkColor":"#BAB5A8"},{"text":"2","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 修改搜索的节点，整体向下移动","darkColor":"#908B7E"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"k","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"0","darkColor":"#E2B159"},{"text":"];","darkColor":"#BAB5A8"},{"text":" // 把最开始的节点放在应该在的位置","darkColor":"#908B7E"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"6148e7d3903bc1da52a54b165b","topic":"分析：","expanded":true,"children":[{"id":"9a2b334417dab069f25cdb09e6","topic":"空间复杂度：","expanded":true,"children":[{"id":"b9cbfd38215a20d92075db0459","topic":"O(1)","expanded":true}]},{"id":"4f381aedaf995282f9b21bcfdd","topic":"时间复杂度：","expanded":true,"children":[{"id":"9abb91554b4a0c60ab1eb950c4","topic":"一个元素的调整：","expanded":true,"children":[{"id":"0ddaecfa787916e7a1c128a0e9","topic":"O(h)","expanded":true,"children":[{"id":"0088bb6a520baecf6270aa8eda","topic":"h是树高度","expanded":true}]}]},{"id":"3e1b46dd863921fc418459b21c","topic":"总的元素调整：","expanded":true,"children":[{"id":"bbca75f2ae0b784da510285ad4","topic":"O(n)","expanded":true,"children":[{"id":"48d9d240829ad263b4c40812c0","topic":"总的元素比较次数不会超过4n","expanded":true}]}]}]}]}]},{"id":"f8da46096668707825108bceeb","topic":"堆排序算法","expanded":true,"children":[{"id":"b06990337dc846414cec3b6111","topic":"思路：","expanded":true,"children":[{"id":"a62b82bc915bdc33b64b0b2795","topic":"每次都把根节点和树的最后一个结点交换，交换后把这个节点和树的联系切断","expanded":true}]},{"id":"b2bb19ec435b670c7e67583fd0","topic":"示意图：","expanded":true,"children":[{"id":"234bdc52118b3c6c03c879e47e","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-492907f5669437.png","width":574,"height":180}}]},{"id":"8778325272b9164610f65bd17e","topic":"代码：","expanded":true,"children":[{"id":"027b9af13ad8f96539a139f5d7","topic":"HeapSort 代码实现","expanded":true,"code":{"lang":"cpp","code":"void HeapSort(ElemType A[], int n) {\n    BuildMaxHeap(A, n);\n    for(int i = n; i > 0; i --) {\n        swap(A[1], A[i]);\n        AdjustHeap(A, 1, n-1); // 注意这里是 n-1 了，因为堆减小了一个\n    }\n}","title":"HeapSort","tokens":[[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"HeapSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"BuildMaxHeap","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"0","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"--)","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"swap","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":"],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"]);","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"AdjustHeap","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"n","darkColor":"#EEECE6"},{"text":"-","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 注意这里是 n-1 了，因为堆减小了一个","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"11b90bb0c32b6862d03c0ad313","topic":"分析：","expanded":true,"children":[{"id":"12080882f539053663c2aa2f90","topic":"空间复杂度：","expanded":true,"children":[{"id":"017ac37f433931dd7d414a6eb8","topic":"O(1)","expanded":true}]},{"id":"e7bba21fc4b8dd0f2dac38ba34","topic":"时间复杂度：","expanded":true,"children":[{"id":"1c98e7eb65aa3fd7a32df86e13","topic":"O(n)","expanded":true}]}]}]},{"id":"e389cacc8ff9d1893f7ab906e5","topic":"总算法分析：","expanded":true,"children":[{"id":"97ba1f0f73295fd3674d19299d","topic":"空间复杂度：","expanded":true,"children":[{"id":"dd1821defec9e04be4c4cb5987","topic":"O(1)","expanded":true}]},{"id":"368b0172691a4b8209bf3bd6b5","topic":"时间复杂度：","expanded":true,"children":[{"id":"159ad71f6839c16bb73c6b8243","topic":"O(nlog2n)","expanded":true,"children":[{"id":"a8380fbeb7dbd50a58a558ec6e","topic":"最好平均最坏都是nlog2n","expanded":true}]}]},{"id":"7d3b86c06d88293acbfc2b2d3b","topic":"稳定性：","expanded":true,"children":[{"id":"926b5c6e9979b7ddbe3579b426","topic":"当然不稳定","expanded":true}]}]}]},{"id":"d9e87648232be9b31a8b4b6ce2","topic":"归并排序","expanded":true,"children":[{"id":"1c0938283cc85f1341d1182749","topic":"思路：","expanded":true,"children":[{"id":"5f3ba31586da408d928f1a72ff","topic":"把多个有序表组合成一个有序表","expanded":true}]},{"id":"34bb41b7cbba2541375a2924c8","topic":"图示：","expanded":true,"children":[{"id":"1a59b906b848284c85ab38e3b7","topic":"一般讨论只说红色部分，但是真正的代码实现是蓝色+红色来实现的","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f5d1f5cfa869c7.png","width":468,"height":352}}]},{"id":"998b62459ca88ad3c9c329d818","topic":"代码：","expanded":true,"children":[{"id":"22d9448d2dfa8b8bb8cadb118f","topic":"递归","expanded":true,"children":[{"id":"86a96a7a960ad7a6bbc09a27dc","topic":"MergeSort 代码实现","expanded":true,"code":{"lang":"cpp","code":"// 8. 归并排序 MergeSort\nElemType *B = (ElemType*)malloc((n+1)*sizeof(ElemType));\nvoid start(ElemType A[], int len) {\n    MergeSort(A, 1, len);\n}\nvoid MergeSort(ElemType A[], int low, int high) {\n    if(low < high) {\n        int mid = (low + high)/2;\n        MergeSort(A, low, mid);\n        MergeSort(A, mid+1, high);\n        Merge(A, low, mid, high); // 进行归并\n    }\n}","title":"MergeSort","tokens":[[{"text":"// 8. 归并排序 MergeSort","darkColor":"#908B7E"}],[{"text":"ElemType","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"*","darkColor":"#BAB5A8"},{"text":"B","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#EEECE6"},{"text":"*)","darkColor":"#BAB5A8"},{"text":"malloc","darkColor":"#6EC0DF"},{"text":"((","darkColor":"#BAB5A8"},{"text":"n","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":")*sizeof(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#EEECE6"},{"text":"));","darkColor":"#BAB5A8"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"start","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"MergeSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"len","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}],[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"MergeSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"low","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"+","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":")/","darkColor":"#BAB5A8"},{"text":"2","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"MergeSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"MergeSort","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"Merge","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"A","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":");","darkColor":"#BAB5A8"},{"text":" // 进行归并","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]},{"id":"5d9ad86da6d9fb8e89ad0bf2b4","topic":"归并","expanded":true,"children":[{"id":"6caa099469dbaece60b208ef59","topic":"Merge 代码实现","expanded":true,"code":{"lang":"cpp","code":"void Merge(ElemType A[], int low, int mid, int high) {\n    // A中 low -> mid 的元素和 mid+1 -> high 的元素都各自有序\n    int i, j, k;\n    for(i = low; i <= high; i ++)\n        B[i] = A[i];\n    i = low, j = mid+1; // i,j分别为B数组中两个归并数组的指针\n    k = i; // 为A数组插入位置的指针\n    while(i <= mid && j <= high) {\n        if(B[i] > B[j])\n            A[k++] = B[i++];\n        else\n            A[k++] = B[j++];\n        // 找到B中大的一项，选择其大的进行插入\n        // A[k++] = B[i] > B[j] ? B[i++] : B[j++];\n    }\n    // 解决数组仍有剩余项的情况\n    while(i <= mid) A[k++] = B[i++];\n    while(j <= high) A[k++] = B[j++];\n}","title":"Merge","tokens":[[{"text":"void","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"Merge","darkColor":"#6EC0DF"},{"text":"(","darkColor":"#BAB5A8"},{"text":"ElemType","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#D5C5AA"},{"text":"[],","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#D5C5AA"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#D5C5AA"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"    // A中 low -> mid 的元素和 mid+1 -> high 的元素都各自有序","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"int","darkColor":"#74CBC4"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"k","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"for","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"++)","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"B","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"];","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"low","darkColor":"#EEECE6"},{"text":",","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":"+","darkColor":"#BAB5A8"},{"text":"1","darkColor":"#E2B159"},{"text":";","darkColor":"#BAB5A8"},{"text":" // i,j分别为B数组中两个归并数组的指针","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"k","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"i","darkColor":"#EEECE6"},{"text":";","darkColor":"#BAB5A8"},{"text":" // 为A数组插入位置的指针","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"&&","darkColor":"#8EA4E2"},{"text":" ","darkColor":"#DEDBD2"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"{","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"if","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"B","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":">","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"B","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"])","darkColor":"#BAB5A8"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"k","darkColor":"#EEECE6"},{"text":"++]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"B","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"++];","darkColor":"#BAB5A8"}],[{"text":"        ","darkColor":"#DEDBD2"},{"text":"else","darkColor":"#8EA4E2"}],[{"text":"            ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"k","darkColor":"#EEECE6"},{"text":"++]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"B","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"++];","darkColor":"#BAB5A8"}],[{"text":"        // 找到B中大的一项，选择其大的进行插入","darkColor":"#908B7E"}],[{"text":"        // A[k++] = B[i] > B[j] ? B[i++] : B[j++];","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"}","darkColor":"#BAB5A8"}],[{"text":"    // 解决数组仍有剩余项的情况","darkColor":"#908B7E"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"mid","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"k","darkColor":"#EEECE6"},{"text":"++]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"B","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"i","darkColor":"#EEECE6"},{"text":"++];","darkColor":"#BAB5A8"}],[{"text":"    ","darkColor":"#DEDBD2"},{"text":"while","darkColor":"#8EA4E2"},{"text":"(","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":" ","darkColor":"#DEDBD2"},{"text":"<=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"high","darkColor":"#EEECE6"},{"text":")","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"A","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"k","darkColor":"#EEECE6"},{"text":"++]","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"=","darkColor":"#BAB5A8"},{"text":" ","darkColor":"#DEDBD2"},{"text":"B","darkColor":"#EEECE6"},{"text":"[","darkColor":"#BAB5A8"},{"text":"j","darkColor":"#EEECE6"},{"text":"++];","darkColor":"#BAB5A8"}],[{"text":"}","darkColor":"#BAB5A8"}]]}}]}]},{"id":"cf88ee3145ea83c822e07bd642","topic":"分析：","expanded":true,"children":[{"id":"4caafd93a84a31656e4bc83c22","topic":"空间复杂度：","expanded":true,"children":[{"id":"0509092423d94038592c9ab18b","topic":"O(n)","expanded":true,"children":[{"id":"61f9391a8bd8d2d08e7aea9451","topic":"递归也有O(log2n)可以忽略","expanded":true}]}]},{"id":"4f78466bd098d7f42757ab2020","topic":"时间复杂度：","expanded":true,"children":[{"id":"183ab21d78eaaf0a7a4daa08b8","topic":"递归O(log2n)，归并O(n)","expanded":true,"children":[{"id":"faf8eef0fbfb728a3cd82a7b87","topic":"总共为O(nlog2n)","expanded":true}]}]},{"id":"f6dbd5c2f71a27db14657bbceb","topic":"稳定性：","expanded":true,"children":[{"id":"d48bb2adc7e95112ad86ca72bf","topic":"✅","expanded":true}]}]},{"id":"5ec99b5cca89a7a023b749f58a","topic":"可以用来给外部排序用，10TB数据请用归并排序","expanded":true},{"id":"3aa5b0d1-6d5d-452d-93fd-261cd701fd30","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"f728476e-e163-4b8c-a24f-6b22013bf002","topic":"16、17、22","expanded":true}]}]},{"id":"7098f0012838acce07e84b6087","topic":"基数排序","expanded":true,"children":[{"id":"f1ae40a7-8c61-4ad8-9ce5-758ce4af690c","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"90b6462a-719b-4587-8b24-9f9fde71f652","topic":"13、21","expanded":true}]},{"id":"14a985f80c68f53407bddbfb22","topic":"思路：","expanded":true,"children":[{"id":"791b0e9fde0b8291773ce81643","topic":"通过多个关键字的比较进行排序","expanded":true}]},{"id":"5ebbf3d6611b12eae35949c1e7","topic":"图示：","expanded":true,"children":[{"id":"016b7f971ca8b9ff35b1db7f3a","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4978cd6407ee66.png","width":572,"height":290}},{"id":"17e97276787b13b035039980f3","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ac9a53065088a8.png","width":579,"height":295}},{"id":"9b0993915ebb1f210ae23b23e1","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8ab27497387e66.png","width":583,"height":292}},{"id":"826a7ad88e1bf21d42cb995546","topic":"三位数","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]},{"id":"0d386190861b6550108b094231","topic":"分析：","expanded":true,"children":[{"id":"507b8e7bcd79b0579038aa4fb0","topic":"设开辟了辅助空间大小为 r","expanded":true},{"id":"650958d0b89a7345320579620e","topic":"设有 n 个元素，需要 d 趟基数排序","expanded":true},{"id":"e4dbf27d06c90f9c0e8f4a59d1","topic":"空间复杂度：","expanded":true,"children":[{"id":"370bc559fedb1e6f74563849d5","topic":"O(r)","expanded":true,"children":[{"id":"6f29dc091eca2ff259890810f3","topic":"r 个队头 + r 个队尾指针","expanded":true}]}]},{"id":"6beb4221786ab78d9260080b1b","topic":"时间复杂度：","expanded":true,"children":[{"id":"f44b1bafe9686b3c53ff9be7c5","topic":"O(d(n+r))","expanded":true,"children":[{"id":"de799d3becb866e018c00b337c","topic":"一共d趟，每趟需要先遍历一遍n个数，然后需要遍历辅助空间把结果串起来","expanded":true}]}]},{"id":"4dfa334f8acba007eb99283042","topic":"稳定性：","expanded":true,"children":[{"id":"8c6a030ac8eaba790237fafc21","topic":"✅","expanded":true}]}]}]},{"id":"d74a2979b2fae0ddd334fa9798","topic":"各种内部排序的比较","expanded":true,"children":[{"id":"ccfada632aeb348353ea895f2a","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-9afcdc96606b5b.png","width":564,"height":307},"children":[{"id":"fbc235d7-c21f-4875-84e1-998fa682aa9c","topic":"答案：","expanded":true,"children":[{"id":"7e34375a-9314-48ac-98e1-44ae3f869041","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-dc2d054a421183.png","width":571,"height":293}}]}]},{"id":"f448cdf772b923e89981db7b19","topic":"小结：","expanded":true,"children":[{"id":"e3e9b810c2c80f0defe458ab6f","topic":"n 较小时","expanded":true,"children":[{"id":"36988dff47c9230b3d615903f6","topic":"使用直插/简单选择排序即可","expanded":true,"children":[{"id":"7f39aea82138d4257c6d295d43","topic":"如果元素的空间较大，可以选择简单选择，移动次数没有这么多","expanded":true}]}]},{"id":"df49f2fbac18cf27eba58801a7","topic":"如果被排序列已经基本有序","expanded":true,"children":[{"id":"1cda10425edaf3571b47883d2d","topic":"使用直插or冒泡","expanded":true,"children":[{"id":"1df8573616fa3d6afd3189745e","topic":"因为有剪枝","expanded":true}]}]},{"id":"d08a2a5fbf3a21d5f23199e7e1","topic":"n 较大时","expanded":true,"children":[{"id":"637a10c2798aef115725e832c2","topic":"用快排、堆排、归并","expanded":true,"children":[{"id":"d7bb824415487b1cb45d9ad501","topic":"快排","expanded":true,"children":[{"id":"ecb9091511fa50da8f4e08e045","topic":"随机情况下最好的","expanded":true}]},{"id":"6d0a3a75e7ca139fe4187b7e1a","topic":"堆排","expanded":true,"children":[{"id":"eafb89c4db39e79a99b40b7bb1","topic":"可以不用辅助空间的O(nlog2n)","expanded":true}]},{"id":"82dade4dc68ac6a987ebd838d1","topic":"归并","expanded":true,"children":[{"id":"f5d9cf4147ca472191787a35bd","topic":"是具有稳定性的O(nlog2n)","expanded":true}]}]}]},{"id":"34892af8de2ba837aed69b6d5b","topic":"n 很大，关键字可拆解","expanded":true,"children":[{"id":"a7d93e4152d83d2ae4f33b62a1","topic":"基数排序","expanded":true}]},{"id":"6708439173bb1f0b914289bc87","topic":"元素空间超级大","expanded":true,"children":[{"id":"67b8111114ba73f513c48a77b2","topic":"建议用链表和链表可以使用的算法，这样移动元素的消耗没有这么大","expanded":true}]}]},{"id":"94ba0178-7598-44b4-b749-d75887dec71d","topic":"考频：高","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"b4ce8bcb-48b6-4c8a-a89f-05f9df3f080b","topic":"12、15、17、19、20、21大、22","expanded":true}]}]},{"id":"6ae9b6743b6955be9cfe999b1d","topic":"外部排序","expanded":true,"children":[{"id":"14218afa-97bf-41d1-8102-c619176cfffd","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"b9146fd5-adf1-4d34-95b3-44282cfcb8b7","topic":"13、19、23大","expanded":true}]},{"id":"2e8bd5c4cf98cdae315fe8730a","topic":"概念","expanded":true,"children":[{"id":"6af81a290f0a69aab5d9aa8428","topic":"外部排序重点优化的是外存调入内存的次数","expanded":true},{"id":"f81ad463dde96b680548191a80","topic":"归并段：","expanded":true,"children":[{"id":"ba23d46c-91b5-4082-b505-69575bab5b92","topic":"初始情况","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f4dbe84e6d46d4.png","width":358,"height":221},"children":[{"id":"381961eeb3d8ccae40c00b66d4","topic":"完成一次归并排序后的新的数据段","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4e359c18e371a3.png","width":597,"height":235},"children":[{"id":"4f08bd6c0738c6b509bb1a493c","topic":"也可以是归并段和归并段形成新的归并段","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f486cacf8eb6a7.png","width":650,"height":222}}]}]}]}]},{"id":"1378271f955b3d1090b668b300","topic":"归并排序","expanded":true,"children":[{"id":"d08a150e67f88d1b0fd6a88921","topic":"采用三个缓冲区即可完成二路归并排序","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-fd0c9124090bee.png","width":421,"height":176},"children":[{"id":"1439ed3ea6aadcc3eecccaf9ed","topic":"加大输入缓冲区的数目可以实现多路归并","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-6c6c5fde0b6119.png","width":522,"height":152}}]}]},{"id":"20e8722ce0a8a22b875daad4ad","topic":"归并排序的复杂度：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"5cdf7033-807a-45e8-8336-4e364ef79427","topic":"增大归并路数能减少归并趟数，但会增加内部排序的时间","expanded":true},{"id":"dcfb5dec2a2bf52c15a30b5034","topic":"败者树","expanded":true,"children":[{"id":"d97b1ef729c8cb5fd0b03960a7","topic":"使得内部归并不受趟数的影响","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"9d9b4f58bdd9637412764b0320","topic":"置换选择排序","expanded":true,"children":[{"id":"6f38f242357a79f825ac7a3f3f","topic":"在构建初始归并段时，生成更少、更长的归并段","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"8488c69bc2f9d56aa4c3f83b81","topic":"多路平衡归并和败者树","expanded":true,"children":[{"id":"e04887da54bbf7a7b968c8ca88","topic":"多路归并的问题，每增加一个归并路数，一次归并就会增加 n 次比较操作，当归并路数大的时候时间消耗会非常恐怖","expanded":true,"children":[{"id":"6bf8e73224581281937bf8d841","topic":"优化：采用败者树","expanded":true}]},{"id":"e1687ee88eaa9939ac564bb99b","topic":"构造流程","expanded":true,"children":[{"id":"ecaa06e9ad49eeb9b5c97b6e5b","topic":"初始情况：","expanded":true,"children":[{"id":"cde91713f82b476089a25b0754","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-222e4b0a9327c1.png","width":467,"height":269}}]},{"id":"8daa6b1dcfabece2fda418fa7c","topic":"构造过程：","expanded":true,"children":[{"id":"b2fbcb868539c7604100ba09c5","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-78ab9273178668.png","width":464,"height":247},"children":[{"id":"3a4941eed1ea89c5107ad92818","topic":"只有胜者才有资格进行向上继续竞争，输掉的就保留在当前黑色节点中","expanded":true}]}]},{"id":"54088bc34fd8b2c575da38391d","topic":"构造完成：","expanded":true,"children":[{"id":"c3287ad62288cc9414dc29d14d","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-3649d61d141a27.png","width":460,"height":237},"children":[{"id":"719a2234785be220f7ea2ace77","topic":"结点记录来自哪个归并段（index），而不是具体的值","expanded":true}]}]},{"id":"5a7abf78b9392c20ac4118ba3c","topic":"下次比较：","expanded":true,"children":[{"id":"8d386d5f9dfb08256d556aed52","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-c2d501e6968115.png","width":484,"height":284},"children":[{"id":"9ff93166686b15bd826099447d","topic":"新的结点和树上各层的胜者进行比拼，最后选出一个新的胜者","expanded":true}]}]}]},{"id":"cd286f669d389c7a3a0e991df4","topic":"复杂度：","expanded":true,"children":[{"id":"34182b6ee6ab1cb8b26f3bfb92","topic":"关键字比较的时间复杂度降低至O(h)，h为树高","expanded":true,"children":[{"id":"1ad9bf40116a732d9758594870","topic":"归并段数越多，树高就越低 -> 复杂度更低","expanded":true}]}]},{"id":"a1b96ceacc193ac70458db733b","topic":"败者树的归并路数：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"ab483ef4feeafef8fb7f8bba17","topic":"有几个文件进行pk就有几个归并路数","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"40a8ae5fbe49066f5c25a90948","topic":"虽然看着是两两进行pk，但是其实宏观来看是8个文件最后决出一个胜者","expanded":true}]}]}]},{"id":"7b18bc12af98ededd74f7a4517","topic":"置换选择排序","expanded":true,"children":[{"id":"d4da55ee0aebbc5d6a0cd9065e","topic":"思路：","expanded":true,"children":[{"id":"3e4aa719626bc19ecb71e88ae8","topic":"尝试构造最大的初始归并段","expanded":true}]},{"id":"a2285f5c47488d184414e89f2f","topic":"示意图：","expanded":true,"children":[{"id":"63495ff45108a3ab085adb2920","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-2aa95c9083c96e.png","width":624,"height":167},"children":[{"id":"89eae24a-c316-4f17-abde-c09e56a677c7","topic":"MINIMAX为当前生成的归并段的最大值","expanded":true}]},{"id":"61da7800a1e8db2ef1a2e8b617","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-795b2f9d7dc5fa.png","width":484,"height":168},"children":[{"id":"d8e8d90d965a49596b42295ebb","topic":"这样就只有3个归并段了","expanded":true}]}]},{"id":"1bba06776d89f746f872390645","topic":"最佳归并树","expanded":true,"children":[{"id":"0cc903e1a33a3248ddbae94566","topic":"归并排序的IO次数：","expanded":true,"children":[{"id":"79b9d4965eb9c56b242cc8c446","topic":"二路归并","expanded":true,"children":[{"id":"07e98aee019bb0a5d86edafe26","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-fb957bc876ea9d.png","width":484,"height":297},"children":[{"id":"54bb1ac9485a4196f5f5a85412","topic":"最佳归并树（哈夫曼树）","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1832ff298e85f4.png","width":298,"height":293}}]}]}]},{"id":"724b573837f9fadcad4d0b45d2","topic":"三路归并","expanded":true,"children":[{"id":"ee39a869f24ba8e94e6ec89daf","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-11779776a97f9a.png","width":580,"height":234},"children":[{"id":"db79ba672e79b63a3a2f48e02a","topic":"用类似哈夫曼树的方法构造：每次找权值最小的三个结点来归并","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b0b6ac206fb92b.png","width":457,"height":286}}]},{"id":"1d2984441f1894841efd4a8828","topic":"如果没有足够的归并段如何处理","expanded":true,"children":[{"id":"d7aa5e4101686a00d72539b546","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-0ed623006cef35.png","width":385,"height":239},"children":[{"id":"673a718fb2e87e78c90d8a2081","topic":"补充长度为0的虚段来凑归并段","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-342f948bc8cb69.png","width":403,"height":254}}]},{"id":"f41b1f8d19a9d74a5c303a27af","topic":"应该补充多少个归并段呢","expanded":true,"children":[{"id":"da2e8b03-496e-44f9-bc46-183d499ee904","topic":"公式法：","expanded":true,"children":[{"id":"6f5a9411-5c8a-4c14-b8e8-2a1ec974aa7c","topic":"k叉归并树：严格的k叉树，设有n0个叶子，nk个分支，总结点为n个。其中nk是整数","expanded":true,"children":[{"id":"ff64397f-cce1-47a4-8e7e-170d99b98492","topic":"需要补充的虚段个数：","expanded":true,"children":[{"id":"c88a476fe4a889cdcee6781c0a","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-19f66454af9796.png","width":402,"height":246}}],"formula":{"tex":"u = (n_0 - 1) \\% (k - 1), \\text{ 补充 } (k - 1) - u \\text{ 个}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mi>u</mi><mo>=</mo><mo stretchy=\"false\">(</mo><msub><mi>n</mi><mn>0</mn></msub><mo>−</mo><mn>1</mn><mo stretchy=\"false\">)</mo><mi mathvariant=\"normal\">%</mi><mo stretchy=\"false\">(</mo><mi>k</mi><mo>−</mo><mn>1</mn><mo stretchy=\"false\">)</mo><mo separator=\"true\">,</mo><mtext> 补充 </mtext><mo stretchy=\"false\">(</mo><mi>k</mi><mo>−</mo><mn>1</mn><mo stretchy=\"false\">)</mo><mo>−</mo><mi>u</mi><mtext> 个</mtext></mrow><annotation encoding=\"application/x-tex\">u = (n_0 - 1) \\% (k - 1), \\text{ 补充 } (k - 1) - u \\text{ 个}</annotation></semantics></math></span>"}}],"formula":{"tex":"\\begin{cases} n = n_0 + n_k \\\\ k n_k = n - 1 \\end{cases} \\implies n_k = \\frac{n_0 - 1}{k - 1}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mrow><mrow><mo fence=\"true\">{</mo><mtable rowspacing=\"0.36em\" columnalign=\"left left\" columnspacing=\"1em\"><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mrow><mi>n</mi><mo>=</mo><msub><mi>n</mi><mn>0</mn></msub><mo>+</mo><msub><mi>n</mi><mi>k</mi></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"false\"><mrow><mi>k</mi><msub><mi>n</mi><mi>k</mi></msub><mo>=</mo><mi>n</mi><mo>−</mo><mn>1</mn></mrow></mstyle></mtd></mtr></mtable></mrow><mtext>  </mtext><mo>⟹</mo><mtext>  </mtext><msub><mi>n</mi><mi>k</mi></msub><mo>=</mo><mfrac><mrow><msub><mi>n</mi><mn>0</mn></msub><mo>−</mo><mn>1</mn></mrow><mrow><mi>k</mi><mo>−</mo><mn>1</mn></mrow></mfrac></mrow><annotation encoding=\"application/x-tex\">\\begin{cases} n = n_0 + n_k \\\\ k n_k = n - 1 \\end{cases} \\implies n_k = \\frac{n_0 - 1}{k - 1}</annotation></semantics></math></span>"}}]},{"id":"5c340400-dd4e-4505-a496-4b94ac7e6206","topic":"考场现推法：","expanded":true,"children":[{"id":"77f5e4f7-8fb5-43b9-baa7-bc735cf3a8eb","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-b0e811c8e80eff.png","width":389,"height":349}}]}]}]}]},{"id":"8c087cbb-6372-4ff7-93bc-a2d320b55bcd","topic":"置换选择后长度不均","expanded":true,"icons":["emoji:💬"],"style":{"borderStyle":"dashed","borderColor":"#F59E0B"}}]}]}]},{"id":"d2cb3c3dc22bb6f2b3673aabd8","topic":"END","expanded":true}]},"summaries":[{"id":"7e18fdd58d58f2561ae32b61f8","parentId":"6369b12b3bab9ac82fbdea94e3","start":0,"end":0,"label":"优化思路：时间空间复杂度"},{"id":"6849f2dad76acfcdb8001bc64c","parentId":"9fea45b5d74b8b95ecca2a967f","start":0,"end":0,"label":"优化思路：减少读写次数"},{"id":"449afad0e42a47c05ab8a99499","parentId":"a6fab73a3678121a896d5a7255","start":0,"end":0,"label":"即递归栈的深度"},{"id":"7328425fdf4a23a9bad059bf5c","parentId":"bbca75f2ae0b784da510285ad4","start":0,"end":0,"label":"记住就行"}]}}}]}}