COMP2017 9017 Assignment 2Due: 23:59 28 March 2024This assignment is worth 10% of your final assessmentTask DescriptionYour task is to create a multi-type linked list data structure and a program that interacts with it. Yourassignment is broken into three tasks that must be completed in order.• The first part is the basic command syntax of the linked lists, creation, removal, viewing etc.• The second part is modifying the lists in place, through insertion and deletion of elements.• The third part is allowing lists to refer to each other in a nested pattern.It is also recommended to read through the specification carefully. You should ensure that you createtest cases that cover a range of possible inputs before beginning to code.1 Make sure you identify andtest for edge cases.Implementation DetailsAll commands are read through standard in, and all output is given through standard out.Part 1: Basic CommandsFor Part 1, your linked lists must support elements of the following types:• int• float• char• stringYour program should take in commands from stdin that will create and manage these multi-typelinked lists. The basic commands are:1Even if you do it on pencil and paper, work through some examples to be sure you understand.1COMP2017 9017• NEW - create a new list• VIEW - view a specific list by its index• TYPE - view a specific list by its index, printing out the types of each element.• VIEW ALL - print the number of lists and each list in order of creation• REMOVE - remove a listThe index for each list should be 1 higher than the last created list’s index, starting from 0 for the firstlist, regardless of how many lists have been removed.Basic ExamplesIn the following examples, "> " denotes the following line as input. Your program must not print it tostdout or read it from stdin. It is included in the formatting only as an indicator, to differentiatethe input from the output of the program.Command keywords are delimited by exactly one (1) space character and should have no leadingand trailing whitespaces2. Be sure to replicate the formatting of these examples exactly, character bycharacter.The NEW CommandThis command takes in a number as input for the initial size of the list. It then reads in an initial valuefor each element to initialise the list. 0 is a valid size, negative numbers are not. Lists are labelledstarting at 0 when they begin to exist, and the label always increments, even if a list is removed.Imagine in the following section that 4 lists have already been created.> NEW 5> hello> 1> 2> 3.14> aList 4: hello -> 1 -> 2 -> 3.14 -> aLists will only be considered as "created" after all lines of the input have been parsed and no erroroccurs.The VIEW CommandThis command prints out the contents of the list at the given index.2except when INSERT ing a string. See below examplesSystems Programming Page 2 of 15COMP2017 9017> VIEW 4hello -> 1 -> 2 -> 3.14 -> aThe TYPE CommandThis command prints out the types of each element at the given list.> TYPE 4string -> int -> int -> float -> charThe VIEW ALL CommandThis command prints out the current set of lists in index-increasing order.> VIEW ALLNumber of lists: 3List 0List 3List 4The REMOVE CommandThis command deletes a list, and prints out the current set of lists again in index-increasing order.> REMOVE 3List 3 has been removed.Number of lists: 2List 0List 4Invalid CommandsA command can be identified from a line if the line strictly begins with exactly the command keyword,and is invalid if its invalid otherwise.If a command is invalid in some way, print INVALID COMMAND: . For example, when there is no List 4:> REMOVE 4INVALID COMMAND: REMOVESystems Programming Page 3 of 15COMP2017 9017If a command cannot be identified, use INPUT. F代 写COMP2017、c/c++ or example:> abracadabraINVALID COMMAND: INPUTIt is up to you to find and prepare for edge cases.Type Rules and ExceptionsThere can be some ambiguity in certain cases for what a given input’s type is. The order for typechecking is as follows:• integer• float• char• stringRequirements for types are as follows:• int can be negative, positive or zero (tests will also not exceed the maximum and minimumvalue for an int type).• float is the same except it will always have a decimal point.3• float should also be printed to 2 decimal places, though they can be read in to any precision.• char is any printable4character in ascii as long as it is singular.• string covers all other cases.• Empty lines in list creation should be considered as string.• string can start with leading and trailing whitespace characters.• Lines containing one int or float can have leading and trailing whitespaces. These will beinterpreted as numbers. (Note that this is the default behaviour of scanf).• All inputs will have a maximum total line length of 128 bytes.> NEW 4> 1.0>> baguette> 5List 4: 1.00 -> -> baguette -> 53The exception being scientific notation which should also be accepted, i.e. 2e-4 = 0.0002. Note thatscanf accepts this type of input by default.4isprint() returns trueSystems Programming Page 4 of 15COMP2017 9017Note the empty line that was interpreted as an empty string, as well as the extra space in " baguette".There will be no test cases that do not fit this description.Note: Curly brackets {} are used in Part 3, and are considered invalid input if they appear in any formother than specified there. 5> NEW 3> 1.0> {}> baguetteINVALID COMMAND: NEW> NEW 3> 1.0> {> wordswords } wordsINVALID COMMAND: NEWExiting the programUpon EOF, the program should free all used dynamic memory, then exit.Part 2: Dynamic ListsIn this part you are to implement two extra commands: INSERT and DELETE.The INSERT CommandThis command takes input of the form INSERT , and insertsthe value at the given index of the given list. It should then print out the new list in the same formatas VIEW, but with the string "List : " before it. For example:> VIEW 1a -> b -> c -> d> INSERT 1 0 BaguettesList 1: Baguettes -> a -> b -> c -> dNegative indices should insert from the end of the list. Indices outside the range are invalid:> VIEW 1a -> b -> c -> d> INSERT 1 -1 BaguettesList 1: a -> b -> c -> d -> Baguettes5For completion of Parts 1 and 2, it is sufficient to raise an error whenever curly brackets are detected. Part3 introduces a single exceptional use which is not an error.Systems Programming Page 5 of 15COMP2017 9017> INSERT 1 97 CroissantsINVALID COMMAND: INSERTThe DELETE COMMANDThis command takes input of the form DELETE and removes the givenindex from the list. It should then print out the new list in the same format as INSERT. The sameconditions on indices apply. For example:> VIEW 1a -> b -> c -> d> DELETE 1 0List 1: b -> c -> d> DELETE 1 -1List 1: b -> c> DELETE 1 4INVALID COMMAND: DELETEPart 3: Nested ListsFor this section, you are to modify your previous code to accept a new type: other lists. This is to amaximum depth of one. This means every list is either a simple list (contains only regular types), ora nested list (contains regular types and simple lists). Nested lists cannot contain other nested lists.Nested lists contain only references to simple list(s). Thus, changes to the simple list should also bereflected in the nested list.To insert a simple list into a nested list, it should be specified with curly brackets. When nested listsare printed, they should be labelled as Nested, like so:> VIEW 1a -> b -> c -> d> NEW 3> first> {1}> lastNested 2: first -> {List 1} -> last> VIEW ALLNumber of lists: 2List 1Nested 2An WX:codehelp