This is the lecture note of CS61A - Lecture 19.
Linked Lists
A linked list is either empty or a first value and the rest of the linked list.
Let's implement this data structure.
1 | class Link: |
Linked List Processing
Let's see an example.
1 | # Example: Range, Map, and Filter for Linked Lists |
- Solution:
1 | def range_link(start, end): |
Linked List Mutation
Let's see an example.
Tree Class
Tree is another recursive computational data structure.
We've already implemented it in Lecture 12 with data abstraction. Now, let's try to implement it again, but with class.
1 | class Tree: |
We can use the Tree class easily.
1 | def fib_tree(n): |