48024 Lecture Notes - Lecture 6: Linked List, Dynamic Array
Study 6: Lists
• Like an array except lists can also add and remove elements, letting the size change
overtime unlike an array.
• Need to import.
Array List
• Stores elements as an array, allocating more space than needed to allow you to add
more elements. When you reach the max, it creates a new array 5 times the size and
copies the previous contents into the new larger array.
• To insert an element, elements are shifted to the right to add the new element in
the desired location.
• An array list is as fast as an array and provides access to any element instantly.
• Adding elements to the beginning can be slow and time consuming.
Linked List
• Elements are stored in objects that are linked together through pointers. Thus it is
easy to change and insert an element.
• Slow to access random elements.
• Fast for inserting and removing items.
find more resources at oneclass.com
find more resources at oneclass.com