Big O of a BST recusive size function.
Hey guys I'm trying to figure out what the big O of my recurisve_size function would be.
For this function would the O be O(n) since the function has to go through all the nodes in order to find the size?
1 2 3 4 5 6 7 8 9
|
template <class T>
int Binary_tree<T>::recursive_size(Binary_node<T> *sub_root) const
{
if(sub_root ==NULL)
return 0;
else
return 1 + recursive_size(sub_root->left) + recursive_size(sub_root->right);
}
|
Last edited on
Topic archived. No new replies allowed.