Question: Objectives: Review C/C++ programming (pointers, structs, arrays, and dynamic memory allocation) and setting up Linux OS on your machine (virtual machine, USB boot, or dual

Objectives: Review C/C++ programming (pointers, structs, arrays, and dynamic memory allocation) and setting up Linux OS on your machine (virtual machine, USB boot, or dual boot)

Note on implementation: To avoid reworking the assignment, implement this program "to the letter" of the specifications.

Program specifications: For this assignment, you will write a C/C++ program (on 64-bit machine with minimum 4GB RAM allocation) to maintain a fixed size library of 1024 documents/lines, whose size randomly ranges between 2MB to 3MB. This library is managed in a FIFO fashion. This library is to be maintained as a set of pointers to "raw" bytes, e.g. array of characters. The software also maintains a separate set of 128 documents/lines, named recent_list, whose size also randomly ranges between 2MB to 3MB. At start up, every document/line in the library and recent_list is individually initialized with random upper case letters: A to Z. Randomly generated duplicate documents are permitted.

Separately, the software maintains a dictionary of words: FIRST, CPP, REVIEW, PROGRAM, ASSIGNMENT, CECS, BEACH, ECS, FALL, SPRING, OS, MAC, LINUX, WINDOWS, LAB. A randomly chosen word from the dictionary is searched (FIFO, i.e. document #0 to document #127) in every document of the recent_list set. A document/line in the recent_list set which does not contain the searched word is ejected/moved to the end of the library & reinitialized (with the same length), and the first document/line from the library is copied to the end of the recent_list set. Therefore, the documents/lines in each list would be constantly shifting relatively. For example, the documents/lines copied from the library to the recent_list are inserted in the same order that they were copied.

For the program demonstration: Prompt the user to enter a word from the dictionary (until the user chooses to quit). Search for the word in the currently updated recent_list. Your program outputs the selected word and the number of documents in the recent_list that were ejected.

Sample scenarios: The word CPP is chosen and found in all of the documents in the recent_list. Next, the word ASSIGNMENT is chosen but is not found in 3 of the documents/lines of the list.

Resulting list & library: Compact the remaining 125 documents of the recent_list (i.e. move documents up to fill any gap), and the first 3 documents of the library are moved to the end of the recent_list sequentially. The remaining 1021 documents in the library are also moved up, and the 3 ejected documents from the recently_list are now at the end of the library, whose contents are reinitialized.

Sample output: CPP: 0 document ejected ASSIGNMENT: 3 documents ejected & reinitialized

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!