Short answer:
Just because the algorithm has log (n) as part of its analysis does not mean that the tree is involved. For example, the following algorithm is very simple: O(log(n)
for(int i = 1; i < n; i = i * 2) print "hello";
As you can see, the tree was not involved. John is also a good example of how a binary search can be performed on a sorted array. They take O (log (n)) time, and there are other code examples that can be created or specified. Therefore, do not make assumptions based on the asymptotic complexity of time; look at the code that you need to know for sure.
More about trees:
Just because the algorithm includes “trees” does not mean O(logn) . You need to know the type of tree and how the action affects the tree.
Some examples:
Inserting or searching for the next unbalanced tree will be O(n) .

An insert or search in the following balanced trees would be like O(log(n)) .
Balanced Binary Tree:

Balanced Tree Grade 3:

Additional comments
If the trees that you use do not have the ability to "balance", than there is a good chance that your operations will be O(n) time not O(logn) . If you use self-balancing trees, then inserts usually take longer, since balancing the trees usually occurs during the insert phase.
James oravec
source share