Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Linked List) 1. Introduction Each book will have attributes: book_id book_name . author_name You may need to add or remove books from the list. You

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

(Linked List) 1. Introduction Each book will have attributes: book_id book_name . author_name You may need to add or remove books from the list. You may also need to sort the list of books. 2. Program and Input Specification You will have an input file containing a list of books. Each line will be treated as a single book's information. Each book's information format will be: book id:book id, book name:book name, book author:author name In command.txt file, you will get corresponding command that you need to execute. You may get add, remove, or sort command. Command formats are add pos:insert position, book_id: book id, book_name: book name, book_author: author name remove keyword:value o keyword is one of: pos, book id, book name, or book_author sort keyword o keyword is one of: book id, book name, or book author Your command file may contain multiple commands. Each line lhae a single command. You will execute all commands sequentially one by one. Assumptions . The input file is a small plain text file; no need to handle binary files. . Each line will be terminated with a new line, 'n', character. Before executing any command, all records will be sequentially added from the input file. If you get same book name or author name, but not same book id, then you need to add the book. If you get an 'add' command, then you will add the book in the list at the provided position. . . . o 0 is the starting index o If you get index number that does not exist in the list, then you will add the record at the end of the list. If you get existing book id, i.e., the book id is the same as an existing book id, you will not add the book. o If you get a 'delete' command with book_name, or book_author keywords, then you will delete all records that matches with the book name or author name If you get 'delete' command with pos keyword, then you will delete that position record. . Index starts from 0. If you get invalid position, one that does not exist, then you do not need to delete any record o o . You may need to handle a maximum 1000 records. . You may get a maximum 100 commands in a single command file. .Book ID will be always five-digit number . If you get an empty line, then you will ignore it. Sorting will be always in ascending order. You need to sort the list based on the provided keyword. All records are case sensitive. The main C++ program will become the executable to be tested by the TAs. The Result file should be written to another text file (output file), provided with the Command line. Notice the input and output files are specified in the command line, not inside the C++ code. Notice also the quotes in the program call, to avoid Unix/Windows getting confused. See part 4. 3. Output Specification The output file will contain the list of records after executing all commands. All records should be processed sequentially from beginning to end. Please, see examples for clarification about the format. 4. Program Execution: The general call to the executable is as follows: ListOperation "input input.txt;command command.txt,output output.txt" You can call the executable with another command line type ListOperation input-input.txt command-command.txt output output.txt 5. Examples Example 1 of input and output, Input21.txt book id:32452, book_name:Data Structures Using C++, book author:D. S. Malilk book id:12452, book_name:Computer Networks, book author:Peterson Davie book_id:32432, book_name:Introduction to Algorithms, book_author:Thomas H Cormen book_id:32423, book_name:Algorithms in C++, book author:Robert Sedgewick Command21.txt sort book id add pos:2 book id:12456, book name:Programming and Data Structures, book author:xxx Command line ListOperation input-input21.txt command-command21.txt outputotput21.txt output21.txt book id:12452, book_name:Computer Networks, book author:Peterson Davie book id:32423, book name:Algorithms in C++, book author Robert Sedgewick book_id:12456, book_name:Programming and Data Structures, book_author:xxx book id:32432, book name:Introduction to Algorithms, book_author:Thomas H Cormen book id:32452, book_name:Data Structures Using C++, book author:D. S. Malilk Explanation: First your program will sort the book list, then it will add another book in the list at position 2, finally it will generate the output. Example 2 of input and output, Input22.txt book_id:32452, book_name:Data Structures Using C++, book author:D. S. Malik book id:12452, book name:Computer Networks, book author:Peterson Davie Command22.txt add pos:2 book id:12452, book name:Introduction to Algorithms, book author:Thomas H. Cormen remove book author:Peterson Davie Command line: ListOperation input-input22.txt command-command22.txt output output22.txt output22.txt book_id:32452, book_name:Data Structures Using C++, book author:D. S. Malik Explanation Book id '12452' matches with existing record, thus the book will not be added. The program will generate output after removing the book by matching the author name. Example 3 of input and output, Input23.txt book id:32452, book_name:Data Structures Using C++, book author:D. S. Malik book_id:12452, book_name:Computer Networks, book author:Peterson Davie book_id:12452, book_name:Introduction to Algorithms, book author:Thomas H Cormen book id:32423, book_name:Computer Networks, book_author:Robert Sedgewick book id:12352, book name:Data Structures Using C++, book author:D. S. Malik

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions