Question: C Programming In this part, you have to implement a linked list that maintains a list of integers in sorted order. Thus, if the list

C Programming

In this part, you have to implement a linked list that maintains a list of integers in sorted order. Thus, if the list contains 2, 5 and 8, then 1 will be inserted at the start of the list, 3 will be inserted between 2 and 5 and 10 will be inserted at the end. The list can contain duplicate elements. Input format: This program takes a file name as an argument from the command line. The file is either blank or contains successive lines of input. Each line contains a character, either i or d, followed by a tab character and then an integer. For each of the lines that starts with i, your program should insert that number in the linked list in sorted order. If it is already there, your program can insert it before or after the existing entry. If the line starts with a d, your program should delete the first value if it is present in the linked list. If there are duplicates your program must delete just the first occurrence of the value. Your program should silently ignore the line if the requested value is not present in the linked list. Output format: At the end of the execution, your program should print the number of nodes in the list in the first line of the output and all unique values of the linked list in sorted order in the next line. Note, while printing the size your program must consider all values, but while printing the value you must print duplicate values just once. The values should be in a single line separated by tabs. There should be no leading or trailing white spaces in the output. Your program should print error (and nothing else) if the file does not exist. Your program should print 0 followed by a blank line if the input file is empty or the resulting linked list has no nodes. Example Execution: Lets assume we have 3 text files with the following contents: file1.txt is empty file2.txt: i 10 i 12 d 10 i 5 file3.txt: d 7 i 10 i 5 i 10 d 5 Then the result will be: $./second file1.txt 0 2 $./second file2.txt 2 5 12 $./second file3.txt 2 10 $./second file4.txt error

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!