Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C program is required. miveland Gintarumbe in linkit Question 2: List operations (40%) You are asked to simulate the operations of a list. In one

C program is required. image text in transcribed
image text in transcribed
image text in transcribed
miveland Gintarumbe in linkit Question 2: List operations (40%) You are asked to simulate the operations of a list. In one test case, there will be only one list. The operations are defined as below. We will use the list {2, 10,5) as an example to illustrate each operation. You can safely assume all operations are valid. Operations Description init (e.g. init 3 7 17 8) Initialize a number list with the specified numbers, the first integer specifies the length of the list (e.g. {7, 17, 8)) Insert a number at the front of the list (e.g. 8, 2, 10,5}) insert Front (e.g. insertFront 8) insertEnd (e.g. insertEnd 8) Insert a number at the end of the list (e.g. {2, 10, 5, 8}) insertAt (e.g. insertAt 8 2) Insert a number (first int) at an index position (second int) (e.g. {2, 10, 8, 5)) delete (e.g. delete 10) Delete all nodes having the same value (e.g. {2,5}) deleteAt Delete the specified node c.y. UCIELE 10) (c.y. 14, deleteAt (e.g. deleteAt 2) Delete the specified node (e.g. {2, 10) 2 Print the integer list with space separating the numbers (e.g. 2 10 5) print (e.g.print) find_kth (e.g. find_kth 2) Print the specified node (e.g. 5) Your program should read the input from the file, and output the answer to another file. The first argument is the input file name, while the second argument is the output file name. Name your program as "lab1-q2.c". Inn. Genantninn manw lines and each lina correennnde to ann aneration Sample Input: init 5 1 2 1 2 1 insert Front 3 insertFront 3 insertEnd 3 print Sample Output: 3 3 1 2 1 2 1 3 Hint: The code below will be helpful in reading the file to EOF char command[20]; while (fscanf(fin, "%s", command) > 0) { // Use if-else or switch-case to handle different commands } Hint: The code below will be helpful in determining the command if (strncmp(command, "init, 4) 0) { // Code about "init" } else if ... Hint: The code below will be helpful in clearing the character array, command memset(command, o, sizeof(command))

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_2

Step: 3

blur-text-image_3

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

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

3. What strategies might you use?

Answered: 1 week ago