Python DSALesson 96Free preview
Linked Lists
This lesson is part of Python · All levels
Summary
This lesson explains linked lists, data structures made up of nodes that are connected through pointers. Each node stores data and pointers to the next node, so that the addition forward can be done without shifting the other elements. You'll learn to make nodes, insert nodes, and search through the entire content of the linked list.
Key points
- Singly linked list consists of nodes that store the value and reference next.
- The head is the first node and the last node usually points to None.
- Adding a node in front costs O(1), while accessing a node to i costs O(n) because it must be tracked from the beginning.
- The double-linked list adds the prev pointer so the traversal can be two-way.
- Linked lists are more memory-efficient for frequently inserted data than arrays that have to shift elements.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.