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

Pensu

Pensu

@pensu-8tNeGU Oct 20, 2024
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???

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Ramani Aswath

    Ramani Aswath

    @ramani-VR4O43 Jul 25, 2011

    This article may help:
    #-Link-Snipped-#
  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Jul 26, 2011

    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

    Pensu

    @pensu-8tNeGU Jul 26, 2011

    @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 recursion.....now its working completely fine....thanks anyway.....😀
  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Jul 26, 2011

    Oh Sure, anytime... 😀