3 votes 3 votes What is the time complexity for insertion in binary tree in worst case? O(1) O(log n) O(n) O(n log n) Programming in C iiith-pgee binary-tree time-complexity + – manikgupta123 asked Apr 28, 2019 manikgupta123 1.7k views answer comment Share Follow See 1 comment See all 1 1 comment reply Lakshman Bhaiya commented Apr 29, 2019 reply Follow Share In the Worst case, it may grow left skew binary tree or right skew binary tree. So, time complexity will be $O(n)$ 2 votes 2 votes Please log in or register to add a comment.
2 votes 2 votes For inserting element as the left child of D(either in a left-skewed binary tree or right skewed binary tree), we have to traverse all elements(i.e. A, B, C, D). Therefore, insertion in the binary tree has worst-case complexity of O(n). gaurav1.yuva answered Apr 29, 2019 gaurav1.yuva comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Worst case scenario when binary tree is skewed therefore O(n). Anup dogrial answered May 30, 2020 Anup dogrial comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes In the worst case tree will be skewed therefore complexity will be O(n) Sanandan answered Sep 11, 2020 Sanandan comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Either the tree is left skewed or right skewed that's why O(n) is correct option ShubhamKumar7352 answered Dec 22, 2022 ShubhamKumar7352 comment Share Follow See all 0 reply Please log in or register to add a comment.