Return to Coding in Java with artEoz – exercises

LinkedList class

  1. Make sure you have the geometrie resource. If necessary, see the Resources import webpage.
  2. The code below creates a list
  1. 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? key_48
  2. Go one step forward. What happens to the three attributes? key_48
  3. Go one more step forward. What happens to the three attributes? key_48
    How many items in total are required for this list of two elements? key_48
    How many objects will be displayed if one adds 8 elements key_48
  4. What is the space used for this memory representation? key_48
  5. Add some items to this list to display the evolution of memory diagrams. What becomes of the last attribute of the instance of LinkedList? key_48
    Write an instruction to know the size of the list. What is the result? key_48
  6. 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. key_48
    Check the evolution of the attributes of the Node instances. What do you notice? key_48
  7. What is the effectivness of the add function? key_48
  8. Using this same add function, write a statement that adds a new item at the beginning of the list. key_48
    What do you notice? key_48
  9. 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). key_48
  10. What is the effectiveness of the remove function? key_48

Back to java exercises list