From the course: Programming Foundations: Algorithms
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Linked lists example - Python Tutorial
From the course: Programming Foundations: Algorithms
Linked lists example
- [Instructor] Let's walk through a coding example of a linked list implementation. So I'm going to open up my link list start file in the start folder, and you can see that I already have written some code here in the starting point. At the top of the file is the class that implements the node type that will hold the data in the linked list. Now I chose to name it node just to be consistent with the terminology that I've been using, but you can call it whatever you want. It's a simple class that just stores a single data field and you can see that there's only a single next field, which indicates that this is a singly linked list. There are methods in this class for getting and setting both the data and the next pointer. The linked list class itself is next, and there are already fields for the head reference, as well as a count field that keeps track of how many data nodes are in the list. There's a utility function down…