This commit is contained in:
krahets
2023-12-28 17:18:44 +08:00
parent 5e0d7327db
commit b8a5bd790b
114 changed files with 860 additions and 863 deletions
@@ -1375,7 +1375,7 @@
<p>Observing the image above, the fundamental unit of a linked list is the "node" object. Each node contains two pieces of data: the "value" of the node and the "reference" to the next node.</p>
<ul>
<li>The first node of a linked list is known as the "head node", and the last one is called the "tail node".</li>
<li>The tail node points to "null", which is represented as <span class="arithmatex">\(\text{null}\)</span> in Java, <span class="arithmatex">\(\text{nullptr}\)</span> in C++, and <span class="arithmatex">\(\text{None}\)</span> in Python.</li>
<li>The tail node points to "null", which is represented as <code>null</code> in Java, <code>nullptr</code> in C++, and <code>None</code> in Python.</li>
<li>In languages that support pointers, like C, C++, Go, and Rust, the aforementioned "reference" should be replaced with a "pointer".</li>
</ul>
<p>As shown in the following code, a linked list node <code>ListNode</code>, apart from containing a value, also needs to store a reference (pointer). Therefore, <strong>a linked list consumes more memory space than an array for the same amount of data</strong>.</p>