Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

input1.txt: string head world digital remove tail remove [2] hello print remove tail output should be: print input2.txt: int tail 23 2 remove [0] 65

image text in transcribed

input1.txt:

string head world digital remove tail remove [2] hello print remove tail

output should be: print

input2.txt:

int tail 23 2 remove [0] 65 5 remove [3] remove [2] 0 45 remove tail 15

output should be: 2 0 15

input3.txt:

char head c remove tail remove tail h w o p e remove head remove tail remove head r

output should be: r o w

to get students familiar with Linked List operations and type template. 1. Input files - The first input line will contain a string indicating the data type of the linked list - Options will either be 'string', 'int' or 'char' - Each input file will only contain a single data type - The second input line will indicate how to insert new data into the linked list. Options will be either 'head' or 'tail'. - If it says 'head', add elements only to the beginning of the linked list for this input file. If it says 'tail', add elements only to the end of the linked list for this input file. - Each input file will only contain a single insert option - Each element will be on its own line. - There are three additional operations: 'remove head', 'remove tail', and 'remove [index]' - If the line says 'remove head', remove the first element in the linked list If the line says 'remove tail', remove the last element in the linked list. If the line says 'remove [index], remove the element at [index] in the linked list - If the index is 0 , remove the head of the linkedlist - If the index is equal to or greater than the amount of elements in the linked list, remove the tail of the linkedlist - Otherwise, remove the element at the specified index - Example: linked list currently is hello, computer, science, world - The operation 'remove [1]' would remove computer since its index is 1 - When reading the input, in and I should be removed before processing the string. 2. Assumptions - The keywords 'head', 'tail', and 'remove' will never appear as data. - No empty lines, but there can have empty files; empty input files should be empty output files. 3. Output files - The output file should display every element in the linked list on a single line, separated by a space. - Empty input files should result in an empty output file

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

Students also viewed these Databases questions