recategorized by
507 views
1 votes
1 votes
give an o(n) algorithm to check whether the given binary tree is bst or not
recategorized by

1 Answer

2 votes
2 votes

INORDER of binary search tree will be always sorted .

  • if you have a binary tree then perfome inorder traversal if it is sorted then tree is binary search tree otherwise it is not a binary search tree.
  • inorder traversal will take O(n) time .

Related questions

0 votes
0 votes
1 answer
1