Let's say I have a binary search tree with N nodes. Or an quad tree, or octtree, if these make any difference.
Then let's say I run an algorithm which changes all the keys in the tree. It seems to be complicated to move stuff around. Perhaps there actually is a good algorithm for this, but let's say I take the simple route: I iterate the tree, store the keys in a list, and rebuild the tree from scratch by repeated re-insertion. That is, a complete rebuild.
What time complexity can I expect to get for doing this kind of rebuilding? There are N
nodes and each insertion takes log N
time, but I can't wrap my head around what will happen as the tree grows.