Elementary Sorts quiz



Consider the data type Temp defined below.
public class Temp implements Comparable<Temp> {
    private final double deg;

    public Temp(double deg) {
       this.deg = deg;
    }

    public int compareTo(Temp that) {       
       double EPS = 0.1;
       if (this.deg < that.deg - EPS)
          return -1;
       if (this.deg > that.deg + EPS)
          return +1;
       return  0;
     }
  }     
Which of the following required properties of the Comparable interface does the compareTo() method violate?

Antisymmetry
Transitivity
Totality
None of the above


How many compares does selection sort make when the input array is already sorted?

linear
quadratic
logarithmic
exponential


How many compares does insertion sort make on an input array that is already sorted?
constant
logarithmic
linear
quadratic


How many possible permutations are there of a deck of 52 playing cards?

252
52*52
52!
5252


What is the maximum number of vertices that can be on the convex hull of a set of N points?

constant
logarithmic
linear
quadratic