Duplicate element in BST

if a Binary tree has a duplicate element (i.e same value in parent and child) either on the left or right child of the parent then will it be a BST?

@10vaibhavsinghnegi,

In a Binary Search Tree (BST), all keys in left subtree of a key must be smaller and all keys in right subtree must be greater. So a bst by definition has distinct keys.

How to allow duplicates where every insertion inserts one more key with a value and every deletion deletes one occurrence?

but if you have to deal with duplicates?
A simple solution is to allow same keys on right side (we could also choose left side).
Or you can store the count of occurences of data along with data, left node, right node of a node.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.