Data Structures Tutorial

Data Structures Tutorial Asymptotic Notation Structure and Union Array Data Structure Linked list Data Structure Type of Linked list Advantages and Disadvantages of linked list Queue Data Structure Implementation of Queue Stack Data Structure Implementation of Stack Sorting Insertion sort Quick sort Selection sort Heap sort Merge sort Bucket sort Count sort Radix sort Shell sort Tree Traversal of the binary tree Binary search tree Graph Spanning tree Linear Search Binary Search Hashing Collision Resolution Techniques

Misc Topic:

Priority Queue in Data Structure Deque in Data Structure Difference Between Linear And Non Linear Data Structures Queue Operations In Data Structure About Data Structures Data Structures Algorithms Types of Data Structures Big O Notations Introduction to Arrays Introduction to 1D-Arrays Operations on 1D-Arrays Introduction to 2D-Arrays Operations on 2D-Arrays Strings in Data Structures String Operations Application of 2D array Bubble Sort Insertion Sort Sorting Algorithms What is DFS Algorithm What Is Graph Data Structure What is the difference between Tree and Graph What is the difference between DFS and BFS Bucket Sort Dijkstra’s vs Bellman-Ford Algorithm Linear Queue Data Structure in C Stack Using Array Stack Using Linked List Recursion in Fibonacci Stack vs Array What is Skewed Binary Tree Primitive Data Structure in C Dynamic memory allocation of structure in C Application of Stack in Data Structures Binary Tree in Data Structures Heap Data Structure Recursion - Factorial and Fibonacci What is B tree what is B+ tree Huffman tree in Data Structures Insertion Sort vs Bubble Sort Adding one to the number represented an array of digits Bitwise Operators and their Important Tricks Blowfish algorithm Bubble Sort vs Selection Sort Hashing and its Applications Heap Sort vs Merge Sort Insertion Sort vs Selection Sort Merge Conflicts and ways to handle them Difference between Stack and Queue AVL tree in data structure c++ Bubble sort algorithm using Javascript Buffer overflow attack with examples Find out the area between two concentric circles Lowest common ancestor in a binary search tree Number of visible boxes putting one inside another Program to calculate the area of the circumcircle of an equilateral triangle Red-black Tree in Data Structures Strictly binary tree in Data Structures 2-3 Trees and Basic Operations on them Asynchronous advantage actor-critic (A3C) Algorithm Bubble Sort vs Heap Sort Digital Search Tree in Data Structures Minimum Spanning Tree Permutation Sort or Bogo Sort Quick Sort vs Merge Sort Boruvkas algorithm Bubble Sort vs Quick Sort Common Operations on various Data Structures Detect and Remove Loop in a Linked List How to Start Learning DSA Print kth least significant bit number Why is Binary Heap Preferred over BST for Priority Queue Bin Packing Problem Binary Tree Inorder Traversal Burning binary tree Equal Sum What is a Threaded Binary Tree? What is a full Binary Tree? Bubble Sort vs Merge Sort B+ Tree Program in Q language Deletion Operation from A B Tree Deletion Operation of the binary search tree in C++ language Does Overloading Work with Inheritance Balanced Binary Tree Binary tree deletion Binary tree insertion Cocktail Sort Comb Sort FIFO approach Operations of B Tree in C++ Language Recaman’s Sequence Tim Sort Understanding Data Processing

Program to calculate the area of the circumcircle of an equilateral triangle

You have given one value which represents the side of the equilateral triangle. You have to find out the area of the circumcircle. Let’s take an example -

Program To Calculate The Area Of The Circumcircle Of An Equilateral Triangle

For the above diagram, we have an equilateral triangle named ABC. We have to find out the area of its circumcircle.

Input-

6

Output-

37.69

Explanation- 6 is the value of the side of an equilateral triangle. By calculating the area of the circumcircle, we get the answer 37.69.

Note: -

What is the equilateral triangle?

Triangle has three sides, and an equilateral triangle is a triangle whose three sides are equal. It means, according to the above diagram, the sides AB, BC, and CA are of the same length.

AB = BC = CA

What is the circumcircle?

A circumcircle is a special type of circle. For various types of polygons, we can get circumcircles. It is a circle which goes through every vertex of the polygon. We can calculate different properties of the circle by using different properties of the polygon. A circumcircle of an equilateral triangle goes through three vertices of the triangle.

Algorithm:-

Step 1: Start

Step 2: The value of the sides of a triangle is taken from the user

Step 3: A function is called to calculate the area.

Step 4: In this function, we take the input value, which represents the side of the triangle.

Step 5: The floating point variable is declared in function to store the area

Step 6: The area is calculated.

Step 7: The value of the calculated area is returned.

Step 8: The returned value will be printed.

Step 9: Stop.

Explanation of Algorithm: - Let's try to understand the algorithm by the above diagram. We have an equilateral triangle ABC whose each side is the same in length ( AB = BC = CA ). If we consider the point 'O' as the centre of the circle that goes through each vertex of the triangle, then the value of OA is the radius of the circle. From geometry, we know that the intersection point of all medians of a triangle is the centre of the circumcircle of the equilateral triangle. In this way, we can get the value of the radius of the circle based on the side of the triangle. So, radius = a/ ( root of 3 ).

The formula of area of circle is

Here r = a/

So, area =

Code: -

// Program in CPP to calculate the area of circum.
Circle of an equilateral triangle
#include <iostream>
#include <math.h>
using namespace std;
// function to calculate the area of circumcircle
// of equilateral triangle
float area_circumscribed(float a)
{
	return (a * a * (3.14 / 3));
}
// Driver code
int main()
{
	float a, Area;
	cin >> a;
	// function calling
	Area = area_circumscribed(a);
	// displaying the area
	cout << " The value of triangle side = " << a;
cout << “Area of CircumCircle = ”  << Area;
	return 0;
}

Program in C

// Program in c to calculate the area of circum
circle of an equilateral triangle
#include <stdio.h>
#define PI 3.14159265
// function to find area of
// circumscribed circle
float area_circumscribed(float a)
{
	return (a * a * (PI / 3));
}
// Driver code
int main()
{
	float a = 6;
	printf("Area of circumscribed circle is :%f",
			area_circumscribed(a));
	return 0;
}


Program in Java

// Program in java to calculate the area of the circum
circle of an equilateral triangle
import java. lang.*;
class jtp {	
	static double PI = 3.14159265;
	// function to find the area of
	// circumscribed circle
	public static double area_circumscribed(double a)
	{
		return (a * a * (PI / 3));
	}
	// Driver code
	public static void main(String[] args)
	{
		double a = 6.0;
		System.out.println("Area of circumscribed circle is :"
		+ area_circumscribed(a));
	}
}

Program in Python

// Program in python to calculate the area of the circum
circle of an equilateral triangle
PI = 3.14159265	
# Function to find the area of
# circumscribed circle
def area_circumscribed(a):
	return (a * a * (PI / 3))	
# Driver code
a = 6.0
print("Area of circumscribed circle is :%f"
       %area_circumscribed(a))

Output:

1.	 The value of triangle side = 6
Area of CircumCircle = 37.69
2.	The value of triangle side = 9
Area of CircumCircle = 84.82
3.	The value of triangle side = 3
Area of CircumCircle = 9.42

Complexity Analysis: -

Time complexity- Here, we need no recursion or looping so we can find the solution within constant time. Time complexity will be O (1).

Space complexity- In this solution, we use constant memory. So, space complexity will be O(1).



ADVERTISEMENT
ADVERTISEMENT