- Prove that every subtree of a binary search tree is a binary search tree.

Been there, done that. What's your answer?

Nope. Show some effort if you expect help with your homework.

A hint, read the definition of a binary tree, then see how it applies to the trees's children.

Proof Let T be a binary search tree, and let S be a subtree of T. Let x
be any element oin S and let TL and TR be the left and right subtrees,
respectively, of x in S. Then since S is a subtree of T, x is also an element
of T, and TL and TR are left and right subtrees of x in T. Therefore,
y x z for every y 2 TL and every z 2 TR. Therefore, S too has the
Binary Search Tree (BST) property.
6

commented: Let the guy do his own homework. Give him a hint, not the answer -2

That sounds correct (assuming you've defined a BST accordingly).

If you want to be really anal you should explicitly point out that S is a binary tree.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.