Computer Science 101
Gregory M. Kapfhammer
Details in the Textbook
What have we learned to so far?
Software engineering tools
Java programming language
Algorithm evaluation techniques
Basic Data structures
Advanced Data structures
Benefits of the node-based lists?
Limitations of the node-based lists?
Cannot access arbitrary positions!
Let's remove those limitations!
Wait, ... how would that work?
Organize the class into four groups
When have methods been slow?
Some example methods
Assume that the implementation uses an array
Consider the inputs and outputs of each method
Determine if the implementation is "efficient"
Justify your response concerning efficiency
Shifting "to the right" for insertion
Shifting "to the left" for removal
Why is this time complexity correct?
Any questions about the array-based approach?
Table 7.1 for the big-Oh time complexities
Cannot actually "grow" an array
Move the contents of an array to a larger one
When the array "overflows" ...
Refer to Figure 7.3 for more details
Step 2: Store A's elements in B
Step 3: Reassign reference to B
Later: Garbage collection of old A
What is the worst-case time complexity?
Well, maybe not so bad ...
What is the cause for optimism?
See Section 7.2 for more details
StringBuilder stores characters in dynamic array
No wonder it is faster than standard method!
Data structure uses O(n) memory
What about shrinking the array?
Be careful not to oscillate!
Any questions about lists and iterators?