Reputation: 143
i have this function that print numbers from Binary tree if the numbers in range [a,b]
public void print_in_range(Node root,int a, int b){ // print all num in [a,b] --> (a < b)
if(root == null)
return;
if(root.value >= a && root.value <= b)
System.out.print(root.value + ",");
print_in_range(root.left, a, b);
print_in_range(root.right, a, b);
}
What is the runtime of the function?
what will be the formula of the function?
For example:
T(n) = 3T(n/4) + n --> T(n) = O(n)
Upvotes: 0
Views: 100
Reputation: 948
u can use the master theorem to calculate the run time complexity of this particular function. you can find the theorem here Complexity of recursive algorithms
Upvotes: 1