Computers and Technology

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);

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 17:30, jacksonthelma82
Data for which there is temporarily no room in ram is diverted to where on your computer? question 9 options: a) the paging file on the hard drive b) the system file on the hard drive c) the memory file on the hard drive d) the cpu cache
Answers: 2
image
Computers and Technology, 24.06.2019 21:30, breannaasmith1122
Along what line of action can the camera move to follow the movement of actors for screen direction? a. along a 90-degree arcb. along a 120-degree arcc. along a 180-degree arcd. along a 360-degree arc
Answers: 1
image
Computers and Technology, 25.06.2019 00:30, marziel24
Which type of cell references are locked and not automatically updated when it’s copied a)formula b)relative c)absolute d)worksheet
Answers: 1
image
Computers and Technology, 25.06.2019 07:10, izearaholland7308
When you “listen” to evaluate an online message, which question should you ask?
Answers: 1
Do you know the correct answer?
Write a C program to take n files containing strings in ascending order (no duplicates within a file...

Questions in other subjects:

Konu
Mathematics, 20.11.2020 20:20
Konu
Mathematics, 20.11.2020 20:20
Konu
Physics, 20.11.2020 20:20
Konu
Mathematics, 20.11.2020 20:20
Konu
Mathematics, 20.11.2020 20:20