Kim created the following interface for Heap. Any comments?
```
public interface Heap
public void add( Comparable
public void setComparator( Comparator
public E top();
public E peek();
public void clear();
public int size();
public boolean isEmpty();
}
```
A couple of comments.
1. Passing in the Comparator in the constructor would be an easier way to ensure that it exists, as opposed to requiring it to be passed in with a separate method. Doing it with a separate method requires that the preconditions of the add method must now specify that Comparator is not null, instead of just the constructor checking that.
2. There is also the possibility that the Comparator and the Comparable element don’t have the same interpretations for <, >, and ==.
3. It isn’t clear what the point is of requiring the parameter to add to be Comparable if you are going to change the ordering through a Comparator.
You might also like to view...
Output __________ are typically used to increase the efficiency of an application by sending larger amounts of data fewer times.
a. objects. b. broadcasters. c. buffers. d. None of the above.
What is the difference in execution between the two following sections of code?
``` 'Example 1 intCounter = 0 Do While intCounter < 10 lstOutput.Items.Add(intCounter * intCounter) intCounter = intCounter + 1 Loop 'Example 2 For intCounter = 0 to 9 lstOutput.Items.Add(intCounter * intCounter) Next intCounter ``` a. The loop in the first example will execute one more time than the second example. b. The first example is an infinite loop. c. Both loops are executed in an identical manner. d. The loop in the first example will never be executed.
Anchor points and line segments together are also known as ____.
A. baselines B. curves C. paths D. logos
Which of the following activities will not be possible if the gateway IP address is set incorrectly on a client's machines?
A. Printing over a local network B. Sniffing the network traffic C. Pinging a remote computer D. Sharing local network files