Java Reference
In-Depth Information
15.
Modify merge sort (Chapter 5) and quicksort so that if a sublist to be sorted is smaller than
some pre-defined size, it is sorted using insertion sort.
16.
You are given a list of n numbers and another number x . You must find the smallest number
in the list that is greater than or equal to x . You must then delete this number from the list
and replace it by a new number y , retaining the list structure. devise ways of solving this
problem using (i) unsorted array (ii) sorted array (iii) sorted linked list (iv) binary search tree
(v) heap.
Which of these is the most efficient?
17.
You are given a (long) list of english words. Write a program to determine which of those
words are anagrams of each other. output consists of each group of anagrams (two or more
words) followed by a blank line. two words are anagrams if they consist of the same letters,
such as (teacher, cheater), (sister, resist).
18.
each value in A[1..n] is either 1, 2 or 3. You are required to find the minimal number of
exchanges to sort the array. For example, the array
2
2
1
3
3
3
2
3
1
1
2
3
4
5
6
7
8
9
can be sorted with four exchanges, in order: (1, 3) (4, 7) (2, 9) (5, 9). another solution is (1, 3) (2, 9) (4, 7)
(5, 9). the array cannot be sorted with less than four exchanges.
Search WWH ::




Custom Search