Java’s built-in Tree Set class uses time in O(log n) for insertion and deletion. It seems that we could build a Θ(n log n) sorting algorithm by simply inserting all of the data into a Tree Set, then traversing the Tree Set inorder (Figure 14–10). The running-time analysis is correct, but this algorithm fails to sort some Array Lists. Why? (Hint: Think about the definition of a Set.)
Figure 14–10
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here