Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I would appreciate comments so I know what's going on. Thanks In advance! Second: Linked List (20 points) In this part, you have to implement

image text in transcribed

I would appreciate comments so I know what's going on. Thanks In advance!

Second: Linked List (20 points) 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 roquested 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 m must consider all values, but while printing There should be no leading or trailing white spaces in the output. Your program should (and nothing else) if the file does not exist. Your program should print 0 followed by 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 progra the value you must print duplicate values just once. The values should be in a single line separated by tabs. print "error ( 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: filel.txt is enpty file2.txt i 10 i 12 d 10 file3.txt: d 7 i 10 i 5 i 10 Then the result will be: $./second file1.txt Second: Linked List (20 points) 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 roquested 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 m must consider all values, but while printing There should be no leading or trailing white spaces in the output. Your program should (and nothing else) if the file does not exist. Your program should print 0 followed by 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 progra the value you must print duplicate values just once. The values should be in a single line separated by tabs. print "error ( 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: filel.txt is enpty file2.txt i 10 i 12 d 10 file3.txt: d 7 i 10 i 5 i 10 Then the result will be: $./second file1.txt

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

Students also viewed these Databases questions

Question

=+ (d) amount due within the discount period.

Answered: 1 week ago

Question

Let {X(t), Answered: 1 week ago

Answered: 1 week ago

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago

Question

8. How would you explain your decisions to the city council?

Answered: 1 week ago