How to construct a Binary Search Tree that contains duplicate entries ?

From Trees chapter in PU/ Data Structure and Algorithm

Asked on 21 Jan, 2021

Like 0 Dislike 225 Views

If entries in a BST are duplicate, how should we construct the tree ?

Add a comment

3 Answers

Anonymous on 21 Jan, 2021 Like 0 Dislike

Also add count data type like.Struct BST_node { int data, Int count, struct BST_node* left, *right } .

Add a comment

Anonymous on 21 Jan, 2021 Like 0 Dislike

Also add count data type like.Struct BST_node { int data, Int count, struct BST_node* left, *right } .

Add a comment

Anonymous on 21 Jan, 2021 Like 0 Dislike

Binary Search Tree are created to hold unique data entries. But if we need to keep duplicate entries, then there can be one strategy : - if (node->data == given_data), then given_data should be kept in the same node. This node should be linked with linked_list or extra pointer to hold duplicate entries.

Add a comment


Add your answer