Skip to main content

Program In C++ to find out the height of binary tree

// Name :- Bakul Gupta
// Email-id :- bakulgupta11@gmail.com

#include<bits/stdc++.h>
using namespace std;
struct Node
{
int key;
Node *left,*right;
Node(int x)
{
left=NULL;
right=NULL;
key=x;
}
};
int height(Node *root)
{
if(root==NULL)
return 0;
else
{
int l=height(root->left);
int r=height(root->right);
return 1 + max(l,r);
}

}

int main()
{
Node *root=new Node(10);
root->left=new Node(20);
root->right=new Node(30);
root->left->left=new Node(40);
root->left->right=new Node(50);
cout<<"\n Height of the tree is :- "<<height(root)<<endl;
return 0;

}

Comments

Popular posts from this blog

ELK Installation | Configuration

How to remove elk stack from the server? This section of the guide defines the procedure for the removal of various components of the elk stack Elasticsearch The various steps that need to be followed, for the removal of the elasticsearch completely from the server. Check the elasticsearch status It is used to check the status of the elasticsearch service. service elasticsearch status How to install elk on the server? Script for installing the elk stack The elk components in the training are installed with the help of this bash script. #! /bin/bash Name : Bakul Gupta Email : bakulgupta11@gmail.com(github.com/bullhacks3) red= `tput setaf 1` green= `tput setaf 2` yellow= `tput setaf 3` blue= `tput setaf 6` grey= `tput setaf 8` reset= `tput op` function help() { echo -e "\n ${yellow} This script is used to install the elasticsearch on the ${red} debian ${yello...

AWS | CloudFront

CloudFront Service used for Content Delivery Network Collection of distributed servers , that are used to give access to the contents to users on the basis of geographic locations. Parameters : Edge Location: Location where the data will be cached Origin: Origin of the files that the CDN will distribute. Origin may include : s3 buckets , elastic laod balancer or route53 Terminilogy : 1. Web Distribution: Used for websites 2. RTMP: Used for media streaming Creating a CloudFront Distribution   STEP 1:- Select the CloudFront service from the AWS services menu STEP 2:- Click on the select distribution option, and choose the type of distribution according to the use case   2.1 Web Distribution   2.2  RTMP Distribution

AWS | S3

S3 Simple Storage Services Works as object storage instead of block storage S3 is one of the most popular services provided by AWS for the purpose of storing the data on the cloud. File size can vary from 0 bytes to 5 TB Stored in buckets ( a folder in the cloud ) S3 is universal namespace       URL :- https://s3-{region-name}.amazonaws.com/{bucket-name} S3  object consists of the following information : 1. Key ( name of the  object ) 2. Value ( contains  the data ) 3. Version 4. Metadata 5. Subresources     5.1 Access List S3  Storage Classes  1. Standard  2. IA [ Infrequently Accessed ] 3. One Zone - IA 4. Glacier ( used for data archival only ) AWS Pricing Parameters : 1. Storage 2. Requests 3. Storage Management Pricing 4. Data Transfer Pricing 5. Transfer Acceleration s3 transfer acceleration? Enable a fast, secure and reliable way of transferring the data f...