Java Reference
In-Depth Information
In the class graderoll, a nine-digit student identification number is
reported with a code consisting five leading Xs and the last four digits.
For instance the code for Student ID 999-44-8901 is XXX-XX-8901.
Write a method that takes as input an array consisting of student identi-
fication numbers and returns a
List<String>
containing all codes that
correspond to two or more students.
12.11
Write routine
groupWords
that takes an array of
String
as its parameter,
and returns a
Map
in which the keys are numbers representing the
length of a
String
and the corresponding value is a
List
of all
String
of that length. The
Map
must be sorted by string length.
12.12
You are given a
Map
that contains an email mailing list address book.
In the
Map
, the keys are aliases, and the corresponding values are lists
consisting of email addresses and other aliases. An email address is
guaranteed to contain the @ sign and an alias is guaranteed to not
contain the @ sign. An example of a
Map
is
12.13
{ faculty=[fran48@fiu.edu,pat37@fiu.edu],
staff=[jls123@fiu.edu,moe45@cis.fiu.edu],
facstaff=[faculty,staff],
all=[facstaff,president@fiu.edu,provost@fiu.edu] }
Write routine
expandAlias
that takes a
Map
and an alias and returns the
Set
of all email address that the alias expands to. For example,
expanding
all
yields a
Set
containing six email addresses.
Note that if the alias parameter is an email address,
expandAlias
returns a
Set
of size one. If the alias parameter is not an email
address, but is an invalid alias (i.e. not in the map), you can return a
Set
of size zero. In writing your code, first assume that there are no
cycles in which an alias eventually includes itself. Eventually handle
the case in which an alias appears more than once in an expansion (by
keeping track of aliases that have already been expanded).
PROGRAMMING PROJECTS
12.14
Storing the character counts in the encoding table gives the uncom-
pression algorithm the ability to perform extra consistency checks.
Add code that verifies that the result of the uncompression has the
same character counts as the encoding table claimed.
Describe and implement a method of storing the encoding table that
uses less space than the trivial method of storing character counts.
12.15
Search WWH ::
Custom Search