![]() |
A wedge is a three-dimensional object with two triangular faces and one rectangular face. Examples: Input: a = 2, b = 5, e = 5, h = 6 Approach:Va is the volume of triangular pyramid i.e. Va = (1 / 3) * area of triangle * (e – a) Total Volume = Va + Vb Note: Volume of the rectangular right wedge = (b * h / 6) * (2 * a + e) where a and b are the side bases, e is the top edge and h is the height of the rectangular right wedge. Using Direct CalculationIn this approach, we are using a direct calculation based on the formula for a rectangular right wedge to find its volume without intermediary calculations of separate components. Example: The below example uses Direct Calculation to find the volume of the wedge.
Output Volume = 45.0 Time Complexity: O(1) Space Complexity: O(1) Using Separate Variables for Triangle and PrismIn this approach, we are using separate variables to calculate the volumes of the triangular pyramid and triangular prism, then adding them to determine the total volume of the rectangular right wedge. Example: The below example uses Separate Variables for Triangle and Prism to find the volume of the wedge.
Output Volume = 45.0 Time Complexity: O(1) Space Complexity: O(1) |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |