What is the 'head' of a linked list?

后端 未结 4 750
野的像风
野的像风 2020-12-24 03:15

I\'m working in linked lists in Java, so I\'m trying to grasp the concept of a single linked list.

head -> 12 -> 34 -> 56 -> null

4条回答
  •  再見小時候
    2020-12-24 03:41

    Before Anything else It should be noted that head is not a separate node, but just a reference to the first node. It keeps the whole list by storing a pointer to the first node.

    Another noted difference is that head is an ordinary local pointer variable which is stored in stack, whereas list nodes gets stored in heap. So In most jargon terms Head is just a local pointer which keeps reference to the first element of a linked list and is mostly initialised with NULL in order to distinguish an empty linked list.

提交回复
热议问题