You are asked to take as input a list of integers that went through several reverse operations, and your task is to retrieve the original list, you may use java.util.Stack and java.util.LinkedList as helpers. The operations were as follows: Select each subpart of the list that contain even integers only. For example, if the list was {5,20,8,7,12,18}, then the selected subparts will be {20,8}, {12,18}. Reverse the selected subpart such as {8,20} and {18,12}. The output should be the original list. Sample Input Sample Output 24 18 2 3579 12 6 9. 2 18 24 35 796 12 As it is shown in the input sample, the first line will have an integer indicating the number of the elements in the list followed by the second line which has the list of items. In the sample input, 9 represents the number of items in the list. As you can see, the subparts that contains only even integers in the given list are {2,18,24} and {6,12}. The corresponding output (which is the original list) is shown in the sample output section.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

 please note that the input should be taken from a txt file you can create one with the information provided in the sample run and the output should be written in another txt file

You are asked to take as input a list of integers that went through several reverse
operations, and your task is to retrieve the original list, you may use java.util.Stack and
java.util.LinkedList as helpers.
The operations were as follows:
Select each subpart of the list that contain even integers only.
For example, if the list was {5,20,8,7,12,18}, then the selected subparts will
be {20,8}, {12,18}.
Reverse the selected subpart such as {8,20} and {18,12}.
The output should be the original list.
Sample Input
Sample Output
9.
24 18 2 3579 12 6
2 18 24 35 796 12
As it is shown in the input sample, the first line will have an integer indicating the
number of the elements in the list followed by the second line which has the list of items.
In the sample input, 9 represents the number of items in the list.
As you can see, the subparts that contains only even integers in the given list are
{2,18,24} and {6,12}. The corresponding output (which is the original list) is shown in
the sample output section.
Transcribed Image Text:You are asked to take as input a list of integers that went through several reverse operations, and your task is to retrieve the original list, you may use java.util.Stack and java.util.LinkedList as helpers. The operations were as follows: Select each subpart of the list that contain even integers only. For example, if the list was {5,20,8,7,12,18}, then the selected subparts will be {20,8}, {12,18}. Reverse the selected subpart such as {8,20} and {18,12}. The output should be the original list. Sample Input Sample Output 9. 24 18 2 3579 12 6 2 18 24 35 796 12 As it is shown in the input sample, the first line will have an integer indicating the number of the elements in the list followed by the second line which has the list of items. In the sample input, 9 represents the number of items in the list. As you can see, the subparts that contains only even integers in the given list are {2,18,24} and {6,12}. The corresponding output (which is the original list) is shown in the sample output section.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education