mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-20 15:30:58 +00:00
deploy
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user