Which of the following represents the time complexity of inserting an element into a binary search tree of nodes, with the tightest upper bound?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
We know that the time complexity of inserting an element into a binary search tree depends on its height. If the tree forms a chain (a vertical line, with only one leaf), then worst case is you need to traverse the entire chain until the leaf to insert an element. There are n nodes in the chain, hence O ( n ) .