Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your friend is a chief architect, who is working on building a skyscraper, in Mumbai. The construction is in such a way that the floors
Your friend is a chief architect, who is working on building a skyscraper, in Mumbai. The construction is in such a way that the floors will be constructed in other factories and they will be assembled. All the constructed sizes will be distinct. The skyscraper needs to be constructed in N days with the following conditions : a Every day a floor is constructed in a separate factory of distinct size. b The floor with the larger size must be placed at the bottom of the building. c The floor with the smaller size must be placed at the top of the building. Note: A floor cannot be assembled in the building until all floors larger in size are placed. As a friend he wants you to build a small program that will help him analyze the construction process, to avoid manual work and errors. Input First Line: contains the total floors N in the building Second Line onwards: Contains N inputs in which the ith integer denotes the size of the floor that will be given to architect by factories on the ith day. Output You are required to print N lines. Print the size of the floor in descending order, which can be assembled. If no floor can be assembled on the ith day, leave the line empty. Sample Test Cases TestCase enter the total no of floors in the building enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : The order of construction is as follows Day: Day: Day: Explanation The largest floor size is available on day itself, hence it will be assembled on day On the second day floor of size is available and cannot be assembled as the floor of size is not available. On the third day floor of size is available and accordingly, the remaining floor will assemble in the order TestCase enter the total no of floors in the building enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : The order of construction is as follows Day: Day: Day: Day: Day: Explanation On the first day, the floor of size is given. But it cannot be assembled as the floor of size is still remaining. On the second day, the floor of size is given so now the floor of sizes and can be assembled On the third and fourth days, floors cannot be assembled as the size of needs to be given yet. Therefore, these lines are empty. On the fifth day, all the floors of sizes and can be placed. Test Case enter the total no of floors in the building enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : enter the floor size given on day : The order of construction is as follows Day: Day: Day: Day: Day: Day: Day: Day: Day: Day: Instructions : You can use any inbuilt java functions to implement the above functionalities You can choose any DataStructureStack Queue, LinkedList to implement the above functionality.
Your friend is a chief architect, who is working on building a skyscraper, in Mumbai. The
construction is in such a way that the floors will be constructed in other factories and they will be
assembled. All the constructed sizes will be distinct.
The skyscraper needs to be constructed in N days with the following conditions :
a Every day a floor is constructed in a separate factory of distinct size.
b The floor with the larger size must be placed at the bottom of the building.
c The floor with the smaller size must be placed at the top of the building.
Note: A floor cannot be assembled in the building until all floors larger in size are placed.
As a friend he wants you to build a small program that will help him analyze the construction
process, to avoid manual work and errors.
Input
First Line: contains the total floors N in the building
Second Line onwards: Contains N inputs in which the ith integer denotes the size of the floor
that will be given to architect by factories on the ith day.
Output
You are required to print N lines. Print the size of the floor in descending order, which can be
assembled.
If no floor can be assembled on the ith day, leave the line empty.
Sample Test Cases
TestCase
enter the total no of floors in the building
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
The order of construction is as follows
Day:
Day:
Day:
Explanation
The largest floor size is available on day itself, hence it will be assembled on day
On the second day floor of size is available and cannot be assembled as the floor of size is
not available.
On the third day floor of size is available and accordingly, the remaining floor will
assemble in the order
TestCase
enter the total no of floors in the building
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
The order of construction is as follows
Day:
Day:
Day:
Day:
Day:
Explanation
On the first day, the floor of size is given. But it cannot be assembled as the floor of size is
still remaining.
On the second day, the floor of size is given so now the floor of sizes and can be
assembled
On the third and fourth days, floors cannot be assembled as the size of needs to be given yet.
Therefore, these lines are empty.
On the fifth day, all the floors of sizes and can be placed.
Test Case
enter the total no of floors in the building
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
enter the floor size given on day :
The order of construction is as follows
Day:
Day:
Day:
Day:
Day:
Day:
Day:
Day:
Day:
Day:
Instructions :
You can use any inbuilt java functions to implement the above functionalities
You can choose any DataStructureStack Queue, LinkedList to implement the above
functionality.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started