Implement a Java program for searching words in a document. To enable efficient word search, your code preprocesses the document, and stores all the words found in the document and the lines where they are found in a hash table (the words are the keys, an

computer science

Description

Implement a Java program for searching words in a document. To enable efficient word search, your code preprocesses the document, and stores all the words found in the document and the lines where they are found in a hash table (the words are the keys, and the lines are the values). You may use Hashtable or HashMap or implement your hash table. For example, if the query word is "algorithm," your program should report that it is not found in the given document; and for query word "data," your program reports that it is found in six lines: [2, 4, 8, 9, 11, 12]. You can check it against this text file to produce the desired results listed in the description: From Wikipedia In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. Different kinds of data structures are suited to different kinds of applications, and some are highly specialized for specific tasks. For example, B-trees are particularly well-suited for implementation of databases, while compiler implementations usually use hash tables to look up identifiers. Data structures provide a means to manage large amounts of data efficiently, such as large databases and internet indexing services. Usually, efficient data structures are a key to designing efficient algorithms. Some formal design methods and programming languages emphasize data structures, rather than algorithms, as the key organizing factor in software design. Storing and retrieving can be carried out on data stored in both main memory and in secondary memory.


Related Questions in computer science category