How to check whether a tree is binary search tree or not???

Hey ppl, this question was asked in amazon technical round. The aspirants were given a binary tree and they had to check whether this tree is a binary search tree or not. Can anyone suggest an algorithm???


  • Ramani Aswath
    Ramani Aswath
    This article may help:
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Binary Search Trees have a constraint of left node and sub nodes of the main node to be smaller and the right node and sub nodes to be larger than the main node. Using that constraint you can manually verify it. ๐Ÿ˜€ Do you need a program or something for it? ๐Ÿ˜
  • Pensu
    @biroramani: thanks for the link....๐Ÿ˜€
    @praveen: nah i got it.....actually i was confused about taking the range for the starting element and i did a mistake in its working completely fine....thanks anyway.....๐Ÿ˜€
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Oh Sure, anytime... ๐Ÿ˜€

You are reading an archived discussion.

Related Posts

I stumbled upon the 'Power Up' plane idea: Power Up gives paper planes an electric boost and I think it's very simple enough for you try it on this weekend....
Free Mock GATE for GATE 2012 Gateforum is conducting a free All India Mock GATE Test for GATE 2012 in below cities. There is no fees for the test, and...
Below are some useful tips for GMAT exam: Practice a lot: To excel in this exam it is important to practice a lot. One of the most important ways to...
Tunebirds is a free service that lets you share music over Twitter. The service lets you share a song or entire playlist over the Twitter. You just have to sign...
Google plus made a lot of noise after its debut few days ago. Now that Google has allowed third-party developers to interact with their service, Google plus custom profile URL...