I was reading binary search tree and was thinking that why do we need BST at all? All the things as far as I know can also be achieve using simple sorted arrays. For e.g. - In order to build a BST having n elements, we requires n*O(log n)
time i.e. O(nlog n)
and lookup time is O(log n)
. But this thing can also be achieve using array. We can have a sorted array(requires O(nlog n)
time), and lookup time in that is also O(log n)
i.e. binary search algo. Then why do we need another data structure at all? Are there any other use/application of BST which make them so special?
--Ravi