subject

Write a C program to take n files containing strings in ascending order (no duplicates within a file) and produce a file out. dat containing a line for each string (in ascending order). Even if a string str appears in multiple files, it should be output only once and, for each string, you should also output the number of files (k) containing the string. This should be done using code similar to:

fprintf(outfp,"%s %d\n",str, k);

1. Your program is to perform only one "heap assisted" merge of all n files simultaneously. At any time, there should be no more than one string from each of the input files being processed by your code. It will be useful to have a table of file pointers and a table of strings. Using a heap implementation with "handles" is highly recommended.

Under no circumstance should your program use multiple binary merges!

2. You may use heap code from the course webpage to get started.
3. Your program will be driven by a file in. dat:
a. The first line will contain the value for n.

b. Each of the remaining n lines will contain a simple file name, i. e. there will not be a directory path.

c. Each of the n files will contain at least one string. The strings will consist of no more than 50 letters and digits.

4. Pseudo-code:
a. Open in. dat, each of the n files, and out. dat.

b. Prime the heap with the first string from each file. The strings will be the priorities, so you will have a minHeap with the smallest (strcmp()) string conceptually at the root.

c. While at least one file has not been exhausted:

1. Remove (conceptually) the minimum string from the heap.

2. if the minimum string is different from the previous minimum Output . . . else Change k

3. Attempt to read in another string from the same file as the string just removed. if EOF heap gets smaller else Put string in heap

d. Final clean-up . . . including output of the last string Write a C program to take n files containing strings in ascending order (no duplicates within a file) and produce a file out. dat containing a line for each string (in ascending order). Even if a string str appears in multiple files, it should be output only once and, for each string, you should also output the number of files (k) containing the string. This should be done using code similar to:
fprintf(outfp,"%s %d\n",str, k);

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 13:30
Jane’s team is using the v-shaped model for their project. during the high-level design phase of the project, testers perform integration testing. what is the purpose of an integration test plan in the v-model of development? a. checks if the team has gathered all the requirements b. checks how the product interacts with external systems c. checks the flow of data in internal modules d. checks how the product works from the client side
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
When creating a budget, log fixed expenses before income. after income. after savings. at the top.
Answers: 1
question
Computers and Technology, 23.06.2019 08:00
Match the items with their respective descriptions.
Answers: 1
question
Computers and Technology, 23.06.2019 10:20
Suppose there is a relation r(a, b, c) with a b+-tree index with search keys (a, b).1. what is the worst-case cost of finding records satisfying 10 < a < 50 using this index, in terms of the number of records n1, retrieved and the height h of the tree? 2. what is the worst-case cost of finding records satisfying 10 < a < 50 and 5 < b < 10 using this index, in terms of the number of records n2 that satisfy this selection, as well as n1 and h defined above? 3. under what conditions on n1 and n2, would the index be an efficient way of finding records satisfying the condition from part (2)?
Answers: 1
You know the right answer?
Write a C program to take n files containing strings in ascending order (no duplicates within a file...
Questions
question
Mathematics, 01.07.2020 15:01
question
Mathematics, 01.07.2020 15:01
question
Mathematics, 01.07.2020 15:01
question
Mathematics, 01.07.2020 15:01
question
Mathematics, 01.07.2020 15:01
question
Biology, 01.07.2020 15:01
Questions on the website: 13722363