assume I have a complete binary tree up-to a certain depth d. What would the time complexity be to traverse (pre-order traversal) this tree.
I am confused because I know that the amount of nodes in the tree is 2^d, so therefore the time complexity would be BigO(2^d)
? because the tree is growing exponentially.
But, upon research on the internet, Everyone states that's traversal is BigO(n)
where n is the number of elements (which would be 2^d
in this case), not BigO(2^d)
, what am I missing?
thanks