CPSC 170 PreLab 3
- Sort the array shown using each algorithm below. In each case, show
the array after each step, whether or not anything in the array changes.
7 2 9 1 3 4 6
- Selection sort
- Insertion sort
- Look at the code for insertion sort in listing 9.9. In the insertionSort
method, what would happen if the index started at 0 instead of 1? (Remember
that the compareTo method simply tells which of two objects is
larger)
- Read section 7.9 in the text on Mouse Events and answer the following
questions.
- What action(s) cause each event below to be generated? Be sure you
clearly distinguish how the last is different from the first two.
- mouse pressed
- mouse released
- mouse clicked
- In the DotsPanel class in listing 7.19 there is an inner class
called DotsListener. In the mousePressed method of this class,
what information does the call to event.getPoint() provide?
(This method refers to an ArrayList object called pointList. We have
not talked about the ArrayList class, but just think of it as
representing
a list with methods to add items to and iterate over the list.)
- Also in the DotsListener inner class:
- Why are there empty definitions
for mouseClicked, mouseReleased, mouseEntered, and mouseExited? (You
may wish to refer to section 6.5 on interfaces.)
- What would happen if we took these out?