You are viewing a single comment's thread. Return to all comments →
It already does the if statement you stated but it just does it implicitly on the recursive call. In terms of savings, you aren't really saving anything because the cost of you doing the if statements would be the trade-off for doing those function calls. Which means this really doesn't change the complexity of this algorithm at all which would still be Big-Oh(N).
The biggest caveat really is if you call root.left or root.right on an None Type root (i.e an empty tree) it would return an AttributeError which the first one would be able to handle.
Actually, if statements are cheaper than function calls. Function calls result in a push to the stack. Which means pushing a pointer to the function name and then pushing each of the parameters.
I agree. If you boil it down and do the exact calculation sure it would be cheaper. But if we are interested in just complexity though its the same as the if call.
The process is observed by the experts where the infromation is preemtive in root data which is neded to be proclaimed and further you can take the information through dell printer support number will provide you the best part