Given N planes. The task is to find the maximum number of line intersections that can be formed through the intersections of N planes.
Input: N = 3
Input: N = 5
Let there be N planes such that no 3 planes intersect in a single line of intersection and no 2 planes are parallel to each other. Adding ‘N+1’th plane to this space should be possible while retaining the above two conditions. In that case, this plane would intersect each of the N planes in ‘N’ distinct lines.
Thus, the ‘N+1’th plane could atmost add ‘N’ new lines to the total count of lines of intersection. Similarly, the Nth plane could add at most “N-1′ distinct lines of intersection. It is easy therefore to see that, for ‘N’ planes, the maximum number of lines of intersection could be:
(N-1) + (N-2) +...+ 1 = N*(N-1)/2
Below is the implementation of the above approach:
Time Complexity: O(1)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Maximum possible intersection by moving centers of line segments
- Count of intersections of M line segments with N vertical lines in XY plane
- Maximum points of intersections possible among X circles and Y straight lines
- Number of intersections between two ranges
- Find the area of the shaded region formed by the intersection of four semicircles in a square
- Find maximum number that can be formed using digits of a given number
- Maximum number of teams that can be formed with given persons
- Check whether a straight line can be formed using N co-ordinate points
- Area of triangle formed by the axes of co-ordinates and a given straight line
- Maximum points of intersection n lines
- Maximum points of intersection n circles
- Number of pairs of lines having integer intersection points
- Count maximum points on same line
- Maximum possible time that can be formed from four digits
- Maximum factors formed by two numbers
- Angle between two Planes in 3D
- Distance between two parallel Planes in 3-D
- Find smallest number formed by inverting digits of given number N
- Find the number of jumps to reach X in the number line from zero
- Largest even number that can be formed by any number of swaps
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.