--- tags: Setup-Summer21 --- # Lecture 8 Setup/Prep In this class, we will convert our functional implementation of lists into an implementation of mutable lists, such as those used in Java. During class, we will - Implement mutable lists. - Add a new method `addLast` that adds an element to the end of the list - Start to optimize some of our methods for time performance ## Prep - Make sure you have the [starter code](https://brown-cs18-master.github.io/content/lectures/07listsimperative/lec07.zip) that was posted for lecture 7 (which we didn't get to using last time -- we'll start from there). - As a refresher, re-draw the memory diagram from the following lines of code with *functional* lists: ``` IList L = newEmptyList.addFirst(3); IList L2 = L.addFirst(5); ``` Propose a memory diagram for the following lines of code with mutable (Java) lists: ``` LinkedList<Integer> L = new LinkedList<Integer>(); L.addFirst(3); L.addFirst(5); ``` We'll start off agreeing on the memory diagram that we want, then work on adjusting the functional list implementation to match that behavior.