This commit is contained in:
krahets
2025-01-02 21:38:22 +08:00
parent 2bbcdf6966
commit e6dbcc8008
327 changed files with 657 additions and 657 deletions

View File

@@ -3587,8 +3587,8 @@
<h3 id="1-key-review">1. &nbsp; Key review<a class="headerlink" href="#1-key-review" title="Permanent link">&para;</a></h3>
<ul>
<li>A binary tree is a non-linear data structure that reflects the "divide and conquer" logic of splitting one into two. Each binary tree node contains a value and two pointers, which point to its left and right child nodes, respectively.</li>
<li>For a node in a binary tree, the tree formed by its left (right) child node and all nodes under it is called the node's left (right) subtree.</li>
<li>Related terminology of binary trees includes root node, leaf node, level, degree, edge, height, and depth, among others.</li>
<li>For a node in a binary tree, its left (right) child node and the tree formed below it are collectively called the node's left (right) subtree.</li>
<li>Terms related to binary trees include root node, leaf node, level, degree, edge, height, and depth.</li>
<li>The operations of initializing a binary tree, inserting nodes, and removing nodes are similar to those of linked list operations.</li>
<li>Common types of binary trees include perfect binary trees, complete binary trees, full binary trees, and balanced binary trees. The perfect binary tree represents the ideal state, while the linked list is the worst state after degradation.</li>
<li>A binary tree can be represented using an array by arranging the node values and empty slots in a level-order traversal sequence and implementing pointers based on the index mapping relationship between parent nodes and child nodes.</li>
@@ -3596,12 +3596,12 @@
<li>Pre-order, in-order, and post-order traversals are all depth-first search methods, reflecting the traversal manner of "going to the end first, then backtracking to continue." They are usually implemented using recursion.</li>
<li>A binary search tree is an efficient data structure for element searching, with the time complexity of search, insert, and remove operations all being <span class="arithmatex">\(O(\log n)\)</span>. When a binary search tree degrades into a linked list, these time complexities deteriorate to <span class="arithmatex">\(O(n)\)</span>.</li>
<li>An AVL tree, also known as a balanced binary search tree, ensures that the tree remains balanced after continuous node insertions and removals through rotation operations.</li>
<li>Rotation operations in an AVL tree include right rotation, left rotation, right-then-left rotation, and left-then-right rotation. After inserting or removing nodes, an AVL tree performs rotation operations from bottom to top to rebalance the tree.</li>
<li>Rotation operations in an AVL tree include right rotation, left rotation, right-left rotation, and left-right rotation. After node insertion or removal, the AVL tree rebalances itself by performing these rotations in a bottom-up manner.</li>
</ul>
<h3 id="2-q-a">2. &nbsp; Q &amp; A<a class="headerlink" href="#2-q-a" title="Permanent link">&para;</a></h3>
<p><strong>Q</strong>: For a binary tree with only one node, are both the height of the tree and the depth of the root node <span class="arithmatex">\(0\)</span>?</p>
<p>Yes, because height and depth are typically defined as "the number of edges passed."</p>
<p><strong>Q</strong>: The insertion and removal in a binary tree are generally completed by a set of operations. What does "a set of operations" refer to here? Can it be understood as the release of resources of the child nodes?</p>
<p><strong>Q</strong>: The insertion and removal in a binary tree are generally accomplished by a set of operations. What does "a set of operations" refer to here? Does it imply releasing the resources of the child nodes?</p>
<p>Taking the binary search tree as an example, the operation of removing a node needs to be handled in three different scenarios, each requiring multiple steps of node operations.</p>
<p><strong>Q</strong>: Why are there three sequences: pre-order, in-order, and post-order for DFS traversal of a binary tree, and what are their uses?</p>
<p>Similar to sequential and reverse traversal of arrays, pre-order, in-order, and post-order traversals are three methods of traversing a binary tree, allowing us to obtain a traversal result in a specific order. For example, in a binary search tree, since the node sizes satisfy <code>left child node value &lt; root node value &lt; right child node value</code>, we can obtain an ordered node sequence by traversing the tree in the "left <span class="arithmatex">\(\rightarrow\)</span> root <span class="arithmatex">\(\rightarrow\)</span> right" priority.</p>
@@ -3807,7 +3807,7 @@ aria-label="Footer"
<div class="md-copyright">
<div class="md-copyright__highlight">
Copyright &copy; 2024 krahets<br>The website content is licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a>
Copyright &copy; 2025 krahets<br>The website content is licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a>
</div>