Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortest possible depth of a leaf in decision tree (comparison sorting algorithm)

What is the shortest possible depth of a leaf in decision tree refering to comparison sorting algorithm ?

Does it change depending on the alogrithm?

like image 935
Kamil Gosciminski Avatar asked Oct 29 '13 15:10

Kamil Gosciminski


1 Answers

The absolute best case happens when we just check every element and see that the data's already sorted.

This will result in n-1 comparisons and thus the leaf will have a depth of n-1.

Practically, this happens for insertion sort (which isn't all that good otherwise though).

Does it change depending on the algorithm?

Absolutely. The best case of an algorithm is a good indicator - the shortest depth for one with O(n log n) best case would be longer than the shortest depth for one with O(n) best case.

like image 137
Bernhard Barker Avatar answered Oct 23 '22 06:10

Bernhard Barker