183k views
5 votes
2. Count all rectangles of positive area formed by segments in a grid of m horizontal lines and n vertical lines.

1 Answer

3 votes

Answer:


(m(m+1))/(2)(n(n+1))/(2)

Explanation:

We have the grid has m horizontal lines and n vertical lines

We have to find the number of rectangles

If the grid is 1×1, there is 1 rectangle.

If the grid is 2×1, there will be 2 + 1 = 3 rectangles

If it grid is 3×1, there will be 3 + 2 + 1 = 6 rectangles.

So is there is
n* 1 there will be
n+(n-1)+(n-2)+(n-3)...............+1=(n(n+1))/(2)

If we add one column to
n* 1 firstly we will have as many rectangles in the 2nd column as the first,

And then we have that same number of
2* m rectangles.

So for
n* 2=(3n(n+1))/(2) rectanglesAfter solving this we can say

For
n* m we have
(m(m+1))/(2)(n(n+1))/(2) rectangles.

User JanithaR
by
8.3k points