Can anyone explain the difference between binary search and binary search tree with example?Are they the same?Reading the internet it seems the second is only for trees and binary search does not follow this rule.And how to check the presence of a number in O(log(n)) time?
-
Possible duplicate - stackoverflow.com/questions/6380231/…stud3nt– stud3nt2019-11-30 12:15:47 +00:00Commented Nov 30, 2019 at 12:15
-
3Does this answer your question? Difference between binary tree and binary search treestud3nt– stud3nt2019-11-30 12:16:00 +00:00Commented Nov 30, 2019 at 12:16
-
Don't confuse yourself.Binary search is a searching algorithm. However BST is a tree data structure which provides efficient searching.Nawnit Sen– Nawnit Sen2019-11-30 14:39:30 +00:00Commented Nov 30, 2019 at 14:39
Add a comment
|
1 Answer
Binary search is an algorithm used on straightforward sorted arrays, which runs in O(log n). Updating a sorted array is O(n).
A binary tree is a data structure that has both O(log n) search and update (Ignoring problems of balancing).
An interesting comparison is at the end of this chapter.