- Make sure you have the geometrie resource. If necessary, see the Resources import webpage.
- The code below creates a list
- Run this code in step-by-step mode. How many attributes are included in the memory diagram of an instance of LinkedList? Can you imagine what they do?
- Go one step forward. What happens to the three attributes?
- Go one more step forward. What happens to the three attributes?
How many items in total are required for this list of two elements?
How many objects will be displayed if one adds 8 elements - What is the space used for this memory representation?
- Add some items to this list to display the evolution of memory diagrams. What becomes of the last attribute of the instance of LinkedList?
Write an instruction to know the size of the list. What is the result? - Use the add function with an integer parameter (to add to a given rank) and write a statement that adds a new item at rank 2.
Check the evolution of the attributes of the Node instances. What do you notice? - What is the effectivness of the add function?
- Using this same add function, write a statement that adds a new item at the beginning of the list.
What do you notice? - Make sure you master this memory representation by checking changes in the memory diagrams when removing the element of rank 2, then the first and last items (remove function).
- What is the effectiveness of the remove function?