Goal
Build three search algorithms to find matching names in two different lists using Java.
____
Problem
1. Read two input files, each containing a sorted list of first names. Assume the input
files will be in the working directory and will be named list1.txt and list2.txt.
2. Find the matching names using three different algorithms. The first list could be
considered the reference list, and the second list would contain the list of names to be
found.
(a) The first search method, named findByBruteForce should use a linear search of
the target list. The inputs to this function will be the two lists.
(b) The second search method, named findByBinarySearch should implement a binary
search algorithm. The inputs to this function will be the two lists.
(c) The third search method, named findByFinesse should implement the tokenized
search discussed in class and summarized below.
Start two markers, one for each list, at the beginning of each list.
Repeat the process outlined below
Compare the two marked items
If both are equal print the name and advance both markers one element.
else since they’re not equal advance the marker that comes first, alphabetically.
EDIT: Go through the list tokenizing word by word. Then compare letter by letter to see if the words are the same. IF they are different then move the marker (A < B < C) alphabetically on the list that it applies to. IF they are the same then move both markers by one and print the name. Thanks for the help.
____
Testing
There are three _les supplied with the assignment:
1. list1.txt which contains the list of five names.
2. list2.txt also contains a list of five names.
3. expectedOutput.txt which is a redirection of the output. This is to be used as the
baseline for running the diff command to confirm the output results and formatting.
(See the Sample Output below for an example of how diff will be used.)
____
Sample output
java Lab01
list1.txt contains:
Akira
Bart
Chase
Declan
Duffman
list2.txt contains:
Atkins
Blinky
Carl
Duffman
Lisa
The method findByBruteForce found the following match(es):
Duffman
The method findByBinarySearch found the following match(es):
Duffman
The method findByFinesse found the following match(es):
Duffman
java Lab01 >myOutput.txt
diff myOutput.txt expectedOutput.txt
Note The diff command will report any differences between the input files. No output means there is no differences between the input files.