Starting from:

$20

ALGORITHMS AND DATA STRUCTURES II PROGRAMMING ASSIGNMENT 4


1 Programming Assignment
The town of NewVille has grown to be a big city now. But as with all the cities in the world, NewVille has many advantages to offer to its inhabitants at a high price. The crime rate has increased and the Police department is trying to update to cope up with the growing database of case records and criminal records. Your job is to implement an efficient algorithm that will help them to search for any string (may be a suspect’s name, may be some incident, or a file number) in their database, so they can solve cases more quickly.
Input: A text file and a string or pattern to search in the text file. Output: The index of the first occurrence of the pattern in the text if the text contains the pattern. Otherwise return the length of the text.
A Java template has been provided containing one empty function and an empty constructor. The constructor KMP takes a string representing the pattern we are searching for and constructs a DFA. The function search takes a string containing the whole text from the given text file, and returns the index of the first occurrence of the pattern in the text if the text contains the string/pattern, otherwise returns the length of the text. You must use the provided Java template as the basis of your submission. You may not change the name (not even change uppercase to lowercase or vice versa), return type or parameters of those functions. The main function in the template contains code to help you test your implementation by reading it from a file. You can use the test cases uploaded on connex for Lab 9. You may modify the main function or any other function, because your submission will be tested using a different main function. You can use any helper methods or any helper classes. You can use any built-in class or write your own classes and data structures. We advise you to put all the classes you write in the same file, but no other class except the provided one should be declared as a public class.

More products