Member-only story

Python Useful Tips — Linked List, Part Two

Tony
6 min readDec 25, 2023

Previously, I introduced the basics of “Python Linked List”, let’s talk about how to write good practice Linked list code in this article.

Writing good linked list code is not an easy task, especially with complex operations like reversing a linked list or merging sorted lists, which are very prone to errors. From my experience in hundreds of interviews, less than 10% of people can write the few lines of code for “linked list reversal” correctly. Why is linked list code so hard to write? And how can one write correct linked list code more comfortably?

Tip One: Understanding the Meaning of Pointers or References

In fact, understanding the structure of a linked list is not very difficult, but once it is mixed with pointers, it can be quite confusing. Therefore, to write correct linked list code, you first need to understand pointers well.

We know that some languages have the concept of “pointers,” like C language; some languages do not have pointers, and instead use “references,” like Java and Python.

Whether it’s a “pointer” or a “reference,” in reality, their meanings are the same; they both store the memory address of the object they point to. In fact, to understand pointers, you just need to remember the following:

--

--

Tony
Tony

No responses yet