Color Scheme
Key Concept
Corresponding Diagram
In-Class Discussion
In-Class Activity
Details in the Textbook
Lists versus stacks and queues
Limitations of the stack?
Limitations of the queue?
Let's remove those limitations!
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?