find height of a tree
C++
// finding height of a binary tree in c++.
int maxDepth(node* node)
{
if (node == NULL)
return 0;
else
{
/* compute the depth of each subtree */
int lDepth = maxDepth(node->left);
int rDepth = maxDepth(node->right);
/* use the larger one */
if (lDepth > rDepth)
return(lDepth + 1);
else return(rDepth + 1);
}
}
Also in C++:
- Title
- size of a matrix using vector c++
- Category
- C++
- Title
- c++ class template
- Category
- C++
- Title
- c++ unittest in ros
- Category
- C++
- Title
- how to output text in c++
- Category
- C++
- Title
- heredar constructor c++
- Category
- C++
- Title
- free or delete in c++
- Category
- C++
- Title
- appending a double to a string c++
- Category
- C++
- Title
- recursion in cpp with reference
- Category
- C++
- Title
- what is meaning of 64 bit integer in c++
- Category
- C++
- Title
- switch c++
- Category
- C++
- Title
- c++ convert const char* to LPCWSTR
- Category
- C++
- Title
- generate random double c++
- Category
- C++
- Title
- switch statement c++
- Category
- C++
- Title
- what is difference between ciel and floor
- Category
- C++
- Title
- euler phi gfg
- Category
- C++
- Title
- struct c++
- Category
- C++
- Title
- Given an undirected graph, count the number of connected components.
- Category
- C++
- Title
- converting char to int in c++
- Category
- C++
- Title
- UPARAM(ref)
- Category
- C++
- Title
- % operator in c++
- Category
- C++
- Title
- binary tree search
- Category
- C++
- Title
- c++ string to stream
- Category
- C++
- Title
- length of string c++
- Category
- C++
- Title
- c++ empty stream
- Category
- C++
- Title
- c++ show time elapsed
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- how to run a c++ program in the background
- Category
- C++
- Title
- transpose matrix eigen c++
- Category
- C++
- Title
- namespace file linking c++
- Category
- C++
- Title
- c++ main function
- Category
- C++
- Title
- shuffle vector c++
- Category
- C++
- Title
- insert function in c++ vector
- Category
- C++
- Title
- if esle in c++
- Category
- C++
- Title
- properties of a set c++
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- number of islands leetcode code
- Category
- C++
- Title
- calling a method on an object c++
- Category
- C++
- Title
- sqrt in c++
- Category
- C++
- Title
- how to compare two strings lexicographically in c++
- Category
- C++
- Title
- double pointers C++
- Category
- C++
- Title
- c++ loop through array
- Category
- C++
- Title
- tellg and seekg c++
- Category
- C++
- Title
- how to check type in c++
- Category
- C++
- Title
- how to print eachh chars in string data type in c++
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- ue4 modular character
- Category
- C++
- Title
- insert elements in array in c++11
- Category
- C++
- Title
- find vector in c++
- Category
- C++
- Title
- arduino falling edge
- Category
- C++
- Title
- find in set of pairs using first value cpp
- Category
- C++
- Title
- c++ client service ros
- Category
- C++
- Title
- lisy stl C++
- Category
- C++
- Title
- longest common subsequence
- Category
- C++
- Title
- vector initialization c++
- Category
- C++
- Title
- min heap declaration in c++ stl
- Category
- C++
- Title
- how to initialize a vector in c++
- Category
- C++
- Title
- length of string in c++
- Category
- C++
- Title
- how to convert n space separated integers in c++
- Category
- C++
- Title
- binary tree deletion
- Category
- C++
- Title
- how to delete an element in vector pair in cpp
- Category
- C++
- Title
- min and max heap in cpp
- Category
- C++
- Title
- c++ remove item from list
- Category
- C++
- Title
- file format not recognized treating as linker script c++
- Category
- C++
- Title
- set of vectors c++
- Category
- C++
- Title
- findung the mode in c++
- Category
- C++
- Title
- c++ throw exception
- Category
- C++
- Title
- c++ string
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- how to iterate over unordered_map c++
- Category
- C++
- Title
- constant variables in c++
- Category
- C++
- Title
- iterative inorder traversal
- Category
- C++
- Title
- gta san andreas
- Category
- C++
- Title
- how to round to nearest whole number unity
- Category
- C++
- Title
- pbds in c++
- Category
- C++
- Title
- All palindromic substrings
- Category
- C++
- Title
- c++ formatting
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- cin.ignore
- Category
- C++
- Title
- passing array to function in c++
- Category
- C++
- Title
- c++ allocate dynamic with initial values
- Category
- C++
- Title
- inserting an element in an set c++
- Category
- C++
- Title
- lambda operator in c++
- Category
- C++
- Title
- fmod c++
- Category
- C++
- Title
- Newton's sqrt in c++
- Category
- C++
- Title
- c++ compare char array
- Category
- C++
- Title
- sum of integer in array c++
- Category
- C++
- Title
- c++ string contains
- Category
- C++
- Title
- what does count function do in hashmap
- Category
- C++
- Title
- comparing strings c++
- Category
- C++
- Title
- how to make a switch case statement in c++
- Category
- C++
- Title
- c++ how to return an empty vector
- Category
- C++
- Title
- double to int c++
- Category
- C++
- Title
- how to append one vector to another c++
- Category
- C++
- Title
- vertical traversal of binary tree
- Category
- C++
- Title
- compile c++ program
- Category
- C++
- Title
- passing a vector to a function c++
- Category
- C++
- Title
- how to get a letter from the users string in c++
- Category
- C++
- Title
- maximum possible number atmost k swaps
- Category
- C++
- Title
- int random string generator c++
- Category
- C++
- Title
- how to iterate through a map in c++
- Category
- C++