Jul 14, 2017 · Level order traversal of binary tree is - 1 2 3 4 5 . Time Complexity: O(n^2) in worst case. For a skewed tree, printGivenLevel() takes O(n) time where n is the number of nodes in the skewed tree. So time complexity of printLevelOrder() is O(n) + O(n-1) + O(n-2) + .. + O(1) which is O(n^2). METHOD 2 (Use Queue) Algorithm: the worst-case time complexity of this algorithm? 13.Prove using a recurrence equation that inorder traversal takes ( n) time. (see book 12.1). 14.Argue that additing n items one by one to an initially empty binary search tree has worst-case time complexity in (nlogn). 3
Post-order Traversal; Generally, we traverse a tree to search or locate a given item or key in the tree or to print all the values it contains. In-order Traversal. In this traversal method, the left subtree is visited first, then the root and later the right sub-tree. We should always remember that every node may represent a subtree itself.