I have a BST and 2 queues that feed into it. In order for insertion and deletion to be in the shortest time possible I need to balance my tree every so often. For this I use the DSW algorithm.
I have all this implemented and it all works great. My problem is I don't know when the best time to balance the tree is.
I've tried looking for papers on this and any kind of information but I can't find any.
I basically need to know when it's optimal to balance the tree such that it isn't too often that it takes too much time but that it's often enough that my insertion & deletion times don't take very long. So in the end the total run time is as short as possible.
Any ideas?