Computer Science 112 Spring 2014
Gregory M. Kapfhammer
Introduction to Computer Science II
Keep in touch!Office Hours, Email, Web, Twitter
Arrays
Index
Element
Capacity
Fixed Size
Challenges?
Out of Bounds
Alternatives?
Linked Lists
Nodes
Singly linked list
Head
Tail
Arrays versus Linked Lists
Insertion
addLast
addFirst
Worst Case Time Complexity?
Deletion
removeFirst
removeLast
Worst Case Time Complexity?
Searching for an item
Worst Case Time Complexity?
Doubly linked list
Trade-offs?
Stacks
push
pop
top
Implementation Choices!
Arrays versus Linked Lists
java.util.Stack
git pull
StackExample.java
Explain the output
git pull
ArrayStack
:Ant compile
ant compile
:Ant ArrayStack
ant ArrayStack
Check the Output!
Exception Handling
Why?
git pull
NodeStack
:Ant compile
ant compile
:Ant NodeStack
ant NodeStack
Check the Output!
Differences in Exceptions
Why?
Queue
Nodes
Double-Ended Queue
Differences?
Let's try it!
Compile
Run
Enhance
toString
Link Hopping?