(15 points) Weiss exercise 6.2. You can just write the code for part (a) out by hand if you wish, but I recommend getting it working in Eclipse and printing out your code. Here is some code that you can use to test your method if you wish:
public static void main(String[] args) {
Collection<Collection<String>> a = new ArrayList<Collection<String>>();String[][] arrays = {{"abc", "def", "ghi"},
{"xyz", "uvw", "abc", "abc"},
{"a", "ab", "abc", "xyz", "abc"}};
for (String[] sArray : arrays){
Collection<String> a1 = new ArrayList<String>();
for (String s: sArray)
a1.add(s);
a.add(a1);
}
System.out.println(count(a, "abc"));
}
2. (5 points) Weiss exercise 6.4. Note that by "less than
quadratic time", we mean O(n log n).
1. Weiss Exercise 6.7
2. Weiss Exercise 6.18
Your program should read strings (one per line) form standard input, and write Strings (one per line) to standard output. The alphabetical part of the sort should ignore case. Hint: Use java.util.Collections.sort().
SAMPLE RUN:
Enter the strings, one per line (CRTL Z to end):
Come
and
sit
by
my
side,
if
you
love
me
Do
not
hasten
to
bid
me
adieu
Just
remember
the
Red
River
Valley
And
the
cowboy
who
loved
you
so
trueSORTED LIST OF STRINGS:
by
Do
if
me
me
my
so
to
and
And
bid
not
Red
sit
the
the
who
you
you
Come
Just
love
true
adieu
loved
River
side,
cowboy
hasten
Valley
Remember