From the course: Python Data Structures: Linked Lists
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Circular Lists - Python Tutorial
From the course: Python Data Structures: Linked Lists
Circular Lists
- [Instructor] This chapter I call variations on a theme because we're going to discuss different types of linked lists. Every type of linked list consists of zero or more nodes connected by links or pointers that allow them to form chains across memory. But what exact shapes those chains take and the rules that govern traversing their pointers are up to interpretation. For example, the circular linked list. What would happen if we took a linked list and made the last link point back to the head? Like the ouroboros of ancient philosophy, it would form a circle. In a circular linked list, there are no null next nodes. It's simply not allowed. You have to be very careful when traversing circular linked lists because if you don't check to see if you reach the head again, you may enter an infinite loop. So let's go to the code and start playing around with these. The easiest way to demonstrate a circular linked list is with our regular linked list class. So here I've created a new linked…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.