Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3) Given n rectangular buildings in a 2-dimensional city, compute the skyline of these buildings, eliminating hidden lines. The main task is to view buildings
3) Given n rectangular buildings in a 2-dimensional city, compute the skyline of these buildings, eliminating hidden lines. The main task is to view buildings from a side and remove all sections that are not visible. All buildings share common bottom and every building is represented by triplet (left, height, right) 'left': is x coordinated of left side (or wall). 'right': is x coordinate of right side 'height': is height of building. 5 10 15 20 25 30 0 5 10 15 20 25 30 A skyline is a collection of rectangular strips. A rectangular strip is represented as a pair (left, height) where left is x coordinate of left side of strip and height is height of strip. Example: Input: Array of buildings {(1,11,5), (2,6,7), (3,13,9), (12,7,16), (14,3,25), (19,18,22), (23,13,29), (24,4,28) } Output: Skyline (an array of rectangular strips) A strip has x coordinate of left side and height (1, 11), (3, 13), (9,0), (12,7), (16,3), (19, 18), (22,3), (25,0) a) Design an algorithm using the recursive design method. Write a pseudo code for your algorithm and provide justifications for your method. b) Trace your algorithm on the above example and show the results. 3) Given n rectangular buildings in a 2-dimensional city, compute the skyline of these buildings, eliminating hidden lines. The main task is to view buildings from a side and remove all sections that are not visible. All buildings share common bottom and every building is represented by triplet (left, height, right) 'left': is x coordinated of left side (or wall). 'right': is x coordinate of right side 'height': is height of building. 5 10 15 20 25 30 0 5 10 15 20 25 30 A skyline is a collection of rectangular strips. A rectangular strip is represented as a pair (left, height) where left is x coordinate of left side of strip and height is height of strip. Example: Input: Array of buildings {(1,11,5), (2,6,7), (3,13,9), (12,7,16), (14,3,25), (19,18,22), (23,13,29), (24,4,28) } Output: Skyline (an array of rectangular strips) A strip has x coordinate of left side and height (1, 11), (3, 13), (9,0), (12,7), (16,3), (19, 18), (22,3), (25,0) a) Design an algorithm using the recursive design method. Write a pseudo code for your algorithm and provide justifications for your method. b) Trace your algorithm on the above example and show the results
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