time complexity of tree traversal