Question
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
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
PLEASE USE C
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 wil be inserted between 2 and 5 and 10 will be inserted at the end. The list can contain duplicate elements Input format: This 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 takes a file name as an argume nt from the command line. The file ram can insert it before or after the existing entry. If the line starts with a 'd', your program ed list. If there are duplicates your program should delete the first value if it is present in the link 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 coside 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 file3.txt d 7 i 10 i 10 d 5 Then the result will be: $./second file1.txt 0 $./second file2.txt 2 5 12 $./second file3.txt 2 10 $./second file4.txt errorStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started