Need programming code done in C

Ch 11 – File Processing – Merge Files

 

One of the greatest advantages that files have compared to other data structures is that they can contain unboundedly large amounts of information. One still must read portions of the information into memory in order to process it, but you do not need to read the entire contents of a file into memory. So, files can contain far more information than can be placed in RAM and yet processing still can proceed.

 

Frequently the information in files is in sorted order. One of the common problems is then to combine the information in two or more sorted files to produce an output file that is in sorted order, but which contains all of the information in the two (or more) original files. This process is known as “merging.”

 

In this assignment you will get a taste of working with sorted sequential files and merging them to produce a combined result file.

 

·      Inputs: FileA.txt and FileB.txt, both sequential text files containing sorted collections of integers

·      Output: FileC.txt, the result from merging FileA.txt and FileB.txt

 

Procedure

1.   Create FileA.txt and write into it 1,000 random integers in the range [10,000..40,000]. The values in FileA.txt must be in ascending order. (Optional addition: The data must contain no duplicated values.)

a.   Display the first 10 values from the file

2.   Create FileB.txt in exactly the same manner as in Step 1, except that the file must contain 1,010 values. Note that there may be items in FileB.txt that do appear in FileA.txt – this is OK.

a.   Display the first 10 values from the file

3.   Merge FileA.txt with FileB.txt yielding FileC.txt, a sequential text file containing all data in ascending order.

a.   Display the first 20 values from the file

 

Deliverables

1.   Your C program pasted into an MS Word document, as usual

2.   Screen shots showing the three required displays

 

Requirements

1.   You should create a function that creates a file containing N random integers in the required range

2.   Another function should display the first K values

3.   You should write a merge function that performs the merge operation

4.   At no point should the merge function make use of any information regarding the sizes of its inputs

5.   You should use these functions to simplify your program design

6.   At no point should your program ever try to read the entire contents of any file into memory all at once

Get Help With a similar task to - Need programming code done in C

Login to view and/or buy answers.. or post an answer

Related Questions

Similar orders to Need programming code done in C
24
Views
1
Answers
JavaScript Assignment
Assignment details in the Word file attached. I just need the files with the code, I will put them into the website myself....
105
Views
1
Answers
46
Views
1
Answers
C++ queue
Use C++ and implement your own queue using linked list that should be templated....
30
Views
1
Answers
creating a website
Description Use Notepad to create a web site about any subject that interests you. In a Mac use the app, Text Edit. The web site must consist of exactly two linked web pages that use the same external style sheet. (If this is not clear to you, please revi...