Java Reference
In-Depth Information
and listIterator(int index) . Both return an  instance of java.util.
ListIterator<E> . The former sets the cursor to the head of the list and the
latter to the element at the specified index.
24.4
( Use the GenericStack class ) Write a program that displays the first 50 prime
numbers in descending order. Use a stack to store the prime numbers.
24.5
( Implement GenericQueue using inheritance ) In Section  24.5, Stacks and
Queues, GenericQueue is implemented using composition. Define a new queue
class that extends java.util.LinkedList .
*24.6
( Generic PriorityQueue using Comparator ) Revise MyPriorityQueue
in Listing 24.9, using a generic parameter for comparing objects. Define a new
constructor with a Comparator as its argument as follows:
PriorityQueue(Comparator<? super E> comparator)
**24.7
( Animation: linked list ) Write a program to animate search, insertion, and dele-
tion in a linked list, as shown in Figure  24.1b. The Search button searches the
specified value in the list. The Delete button deletes the specified value from the
list. The Insert button appends the value into the list if the index is not specified;
otherwise, it inserts the value into the specified index in the list.
*24.8
( Animation: array list ) Write a program to animate search, insertion, and deletion
in an array list, as shown in Figure 24.1a. The Search button searches the specified
value in the list. The Delete button deletes the specified value from the list. The
Insert button appends the value into the list if the index is not specified; otherwise,
it inserts the value into the specified index in the list.
*24.9
( Animation: array list in slow motion ) Improve the animation in the preceding
programming exercise by showing the insertion and deletion operations
in a slow motion, as shown at http://www.cs.armstrong.edu/liang/animation/
ArrayListAnimationInSlowMotion.html .
*24.10
( Animation: stack ) Write a program to animate push and pop in a stack, as shown
in Figure 24.20a.
*24.11
( Animation: doubly linked list ) Write a program to animate search, insertion,
and deletion in a doubly linked list, as shown in Figure 24.24. The Search button
searches the specified value in the list. The Delete button deletes the specified
value from the list. The Insert button appends the value into the list if the index
is not specified; otherwise, it inserts the value into the specified index in the
list. Also add two buttons named Forward Traversal and Backward Traversal
for displaying the elements in a forward and backward order, respectively, using
iterators.
F IGURE 24.24
The program animates the work of a doubly linked list.
 
Search WWH ::




Custom Search