• Register
2 votes

Problem :

Currently I am preparing for interview and I am stuck with one doubt related to binary tree as below

“The time required in best case for search operation in binary tree is”

Can somebody solve my doubt related to binary tree?

8 5 2
3,230 points

1 Answer

2 votes

Solution :

I was going through the long list of questions and after reading your question I came to know that you are preparing for some interview so I am trying to answer it for you.

The time taken by balanced binary tree search tree for worst case, best case and average case is as below:

For Worst case lookup the time taken is O(log n).

For Best case lookup the time taken is O(1).

For Average case lookup the time taken is O(log n).

The worst case look up in the binary tree is the most exciting and also it is very easily observed by recognizing its first level of the binary tree which has just one node and the second has only two nodes and the third one has only four nodes and so on like this. So we can say that the number of nodes in the binary tree for depth n is exactly 2^n - 1.

8 4
5,680 points

Related questions

1 vote
1 answer 11 views
Problem: I was studying the data structure and ended up here in (BST) Binary Search Tree. I do understand how the search tree works. Now I want to write a python program that reflects the BST and its operation. Could you please help me to write such a program? I would recognize your help. Thanks.
asked Jun 26 adamSw 11.3k points
1 vote
1 answer 43 views
Problem: I am very new to Java and all its concepts. I want to know what is the need of build-time dependency’s presence when any application is run ? I am struggling to get this information but I am unable to find much details about this concept. Please help me in getting all the details of the concept.
asked May 18 Martin K 6.6k points
0 votes
1 answer 27 views
I want to know how to trace the count of 1 in the binary representation.
asked Sep 17 Daniel Anderson 4k points
0 votes
2 answers 147 views
Problem : I have below doubts regarding sorting: What is the smallest possible depth of a leaf in a decision tree for a comparison sort? Does it change depending on the algorithm? Can anybody clear my doubts?
asked Dec 4, 2019 alecxe 7.5k points