Java Reference
In-Depth Information
The files listed are available.
ArrayStack.java
Contains the implementation of an array-based
stack.
ArrayQueue.java
Contains the implementation of an array-based
queue.
ListStack.java
Contains the implementation of a linked list-based
stack.
ListQueue.java
Contains the implementation of a linked list-based
queue.
Stack.java
Contains the implementation of a Collections API
stack.
IN SHORT
16.1
Draw the stack and queue data structures (for both the array and
linked list implementations) for each step in the following sequence:
add
(1),
add
(2),
remove
,
add
(3),
add
(4),
remove
,
remove
,
add
(5).
Assume an initial size of 3 for the array implementation.
IN PRACTICE
16.2
Add constructors to the
ArrayStack
and
ArrayQueue
classes that allow
the user to specify an initial capacity.
Compare the running times for the array and linked list versions of
the stack class. Use
Integer
objects.
16.3
Write a
main
that declares and uses a stack of
Integer
and a stack of
Double
simultaneously.
16.4
In package
weiss.util
, provide a
Deque
interface, an
ArrayDeque
class,
and modify
LinkedList
to implement
Deque
.
16.5
Implement the array-based stack class with an
ArrayList
. What are
the advantages and disadvantages of this approach?
16.6
Implement the array-based queue class with an
ArrayList
. What are
the advantages and disadvantages of this approach?
16.7
Search WWH ::
Custom Search