Linked lists are connected to the topic of trees in computer science.
A linked list is a LINEAR SEQUENCE of NODES! (Hence the connection to trees)
The front of the sequence may be referred to as the HEAD, while the back of the sequence is referred to as the TAIL.
It is important to be able to understand the meaning of a linked list, which for me was cleared up by the following:
"a linked list:
- a value and a sub-list (the rest of the linked list)
- a sequence of nodes, each with a value and a reference to the next node"
In the examples I examined, a linked list as whole may be called a "wrapper" class because it can bundle information about the whole linked list.
Just as trees were traversed, linked lists may also be traversed. The common code for traversing a linked list in python is:
current = self.front
while <some condition>:
<do something to current node>
current = current.nxt
It is important to note that mutating code for linked lists, if gone too far, one may make the necessary changes in the previous node.
I found mutating the code interesting but not a topic that is comfortable immediately. Once I revisted the topic, my understanding improved.
Overall, linked lists are an interesting topic in computer science.
Until next time, keep linking!
Feel free to leave a comment.
A linked list is a LINEAR SEQUENCE of NODES! (Hence the connection to trees)
The front of the sequence may be referred to as the HEAD, while the back of the sequence is referred to as the TAIL.
It is important to be able to understand the meaning of a linked list, which for me was cleared up by the following:
"a linked list:
- a value and a sub-list (the rest of the linked list)
- a sequence of nodes, each with a value and a reference to the next node"
In the examples I examined, a linked list as whole may be called a "wrapper" class because it can bundle information about the whole linked list.
Just as trees were traversed, linked lists may also be traversed. The common code for traversing a linked list in python is:
current = self.front
while <some condition>:
<do something to current node>
current = current.nxt
It is important to note that mutating code for linked lists, if gone too far, one may make the necessary changes in the previous node.
I found mutating the code interesting but not a topic that is comfortable immediately. Once I revisted the topic, my understanding improved.
Overall, linked lists are an interesting topic in computer science.
Until next time, keep linking!
Feel free to leave a comment.
No comments:
Post a Comment