![]() |
VOOZH | about |
Examples :
Input : a = 5, b = 7, c = 8 Output : Area of a triangle is 17.320508 Input : a = 3, b = 4, c = 5 Output : Area of a triangle is 6.000000
Approach: The area of a triangle can simply be evaluated using following formula.
where a, b and c are lengths of sides of triangle, and
s = (a+b+c)/2
Below is the implementation of the above approach:
Area is 6
Time Complexity: O(log2n)
Auxiliary Space: O(1), since no extra space has been taken.
Approach: If given coordinates of three corners, we can apply the Shoelace formula for the area below.
2
Time Complexity: O(n)
Auxiliary Space: O(1)