An “inverted file” is a critical data structure for implementing applications like the index of a book, or a web search engine.  Given a document D (which can be viewed as an unordered, numbered list of words), an inverted file is an ordered list of words L such that for each word W in L, we store the indices of the places in D where W appears.  Write a C# program (from scratch please, written by yourself (ask instructor if you are stuck), not borrowed from any other sources) that reads in a list of words separated by spaces from a text file, then uses an efficient O(N) algorithm to create the inverted file index (hint: consider the topic of this chapter, consider using a Dictionary/hashtable to help you), and writes this index out to another file or prints it to the screen.  Each line of the output file should start with the next word (the words should be listed in alphabetical order, and this sorting does not have to be part of the O(N) runtime complexity, e.g. you can use regular O(N log N) complexity sorting algorithms), then the rest of the line should contain a sequence of integers, representing the indexes where that word appeared in the original input text file.  (Assume the index of the first word in the original file is zero.)   You can consider punctuation to be part of the word (so for example, “hello” and “hello!” would be considered different words). Example input file: Hello world hello world hello Output file: hello 2 4 Hello 0 world 1 3

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
An “inverted file” is a critical data structure for implementing applications like the index of a book, or a web search engine.  Given a document D (which can be viewed as an unordered, numbered list of words), an inverted file is an ordered list of words L such that for each word W in L, we store the indices of the places in D where W appears.  Write a C# program (from scratch please, written by yourself (ask instructor if you are stuck), not borrowed from any other sources) that reads in a list of words separated by spaces from a text file, then uses an efficient O(N) algorithm to create the inverted file index (hint: consider the topic of this chapter, consider using a Dictionary/hashtable to help you), and writes this index out to another file or prints it to the screen.  Each line of the output file should start with the next word (the words should be listed in alphabetical order, and this sorting does not have to be part of the O(N) runtime complexity, e.g. you can use regular O(N log N) complexity sorting algorithms), then the rest of the line should contain a sequence of integers, representing the indexes where that word appeared in the original input text file.  (Assume the index of the first word in the original file is zero.)   You can consider punctuation to be part of the word (so for example, “hello” and “hello!” would be considered different words).
Example input file:
Hello world hello world hello
Output file:
hello 2 4
Hello 0
world 1 3
Expert Solution
Step 1

To perform the file operation, store the words in input file named as - input.txt.

Now while running the program pass the input.txt along with script. 

For example - The script name is invertedWordIndex.cs, then to run this use the step.

-> cse invertedWordIndex.cs // compile it first

->invertedWordIndex input.txt output.txt

Here output will store in output.txt

Run the below code in command line.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Potential Method of Analysis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education