How to implement a Multiset with a RedBlack Tree?

572 Views Asked by At

I need some general background here, and I can't find it online..

My main doubt is, if I want to implement a Multiset structure with a redblack tree, do I have to put in the RB Tree every element of the Multiset (every repeated element also..) or is there a way to save the unique elements and their multiplicity?

All this should be done only with one redblack tree, no other structures. (This is for a homework as you may have guessed..)

1

There are 1 best solutions below

1
On

Just store the number of instances (>0) in each leaf.