Given N points on the plane, ( X1, Y1 ), ( X2, Y2 ), ( X3, Y3 ), ……, ( XN, YN ). The task is to calculate the minimum length of the shorter side of the triangle. and the path or points to place an isosceles triangle with any two sides of the triangle on the coordinate axis ( X axis and Y axis ) to cover all points.
Note: A point is covered if it lies inside the triangle or on the side of the triangle.
Input: (1, 3), (1, 1), (2, 1), (2, 2)
Output: Length -> 4 , Path -> ( 1, 4 ) and ( 4, 1 )
Input: (1, 2), (1, 1), (2, 1)
Output: Length -> 3 , Path -> ( 1, 3 ) and ( 3, 1 )
In the first example, the minimum length of the shortest path is equal to the maximum sum of the points, which is 1+3 or 2+2. So the path which will cover all the points is (1, 4) and (4, 1) on the coordinate axis.
Below is the step by step algorithm to solve this problem:
- Initialize ‘N’ points on a plane.
- Traverse through each point and find the sum of each point and store it in a variable ‘answer’.
- Replace the next maximum sum of the points with the previous sum.
- Then you will get the path on a coordinate axis ( 1, answer ) and ( answer, 1 ) which will cover all the points of isosceles triangle.
Below is the implementation of above algorithm:
Length -> 5 Path -> ( 1, 5 )and ( 5, 1 )
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Minimum Sum Path in a Triangle
- Minimum and maximum possible length of the third side of a triangle
- Shortest path from source to destination such that edge weights along path are alternatively increasing and decreasing
- Find the length of the median of a Triangle if length of sides are given
- Shortest path in a Binary Maze
- Maximum path sum in a triangle.
- Maximum path sum in an Inverted triangle | SET 2
- Maximum sum of a path in a Right Number Triangle
- Length of remaining two sides of a Triangle from a given side and its adjacent angles
- Minimum height of a triangle with given base and area
- Convert the undirected graph into directed graph such that there is no path of length greater than 1
- Minimum number of Circular obstacles required to obstruct the path in a Grid
- Minimum Cost Path to visit all nodes situated at the Circumference of Circular Road
- Number of K length subsequences with minimum sum
- Minimum length of square to contain at least half of the given Coordinates
- Rectangle with minimum possible difference between the length and the width
- Biggest Reuleaux Triangle within a Square which is inscribed within a Right angle Triangle
- Area of Triangle using Side-Angle-Side (length of two sides and the included angle)
- Minimum length subarray containing all unique elements after Q operations
- Program to print a Hollow Triangle inside a Triangle
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.