Changes 9/16/14
Java:
- Read more in the Java book, started looking at the ADT List structure
- So far the book has been walking through an implementation of a List class that uses an array to store items and has methods to add, remove, etc.
- Some of it is review from AP Comp Sci, like how variables deal with actual objects in memory
- One approach to having a list with no maximum length is to double the size of the array each time it becomes full. This is better than just adding 1 slot when one is needed, because you end up having to do less operations as more and more items are added.
Nice post. Yes, doubling the size of the storage when it becomes full is a standard approach to this problem, even though it may not be immediately apparent that this is more efficient that add one new item each time one is needed. That's with an array, that is. Linked lists are designed for situations where new items often need to be added or removed. Insertion and deletion in a linked list is an O(n) operation, where in an array it is O(nlogn).
ReplyDelete