• Home
  • Help
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search

 
  • 0 Vote(s) - 0 Average

Describe union by size

#1
11-30-2019, 04:49 AM
Union by size keeps track of group sizes when you join them together. I always prefer this approach because it stops trees from stretching out too far. You attach the smaller bunch straight to the bigger one every time. That choice makes the whole thing grow slower overall. I find it easier to manage than just picking randomly.

You see the height stays low as a result. I tested this idea on paper once and it worked better than expected. But you might notice the balance improves fast with repeated merges. Perhaps you link two equal sizes and then the new count doubles for one root. Now the next join has a clear winner to follow. Also the smaller side climbs up without adding extra layers much. I like how this tames uneven growth in practice.

Or you could ignore sizes and watch the structure get messy quick. I tried that early on and regretted the extra steps later. You end up with longer paths that slow searches down. Then size tracking fixes it by favoring the heavy side always. Maybe you wonder about the count updates but they stay simple with one addition per merge. I handle that by storing the numbers right at the roots.

You get better performance across many operations this way. I recall running through examples where size helped cut the total work in half compared to naive joins. But you still need to update the size value after each link. Perhaps the key lies in never letting small groups pull the height up. Now the trees flatten naturally over time. Also this method pairs well with other tricks for even faster results. I see it as a smart default for most cases you run into.

You attach based on current counts so the larger absorbs the rest. I think this prevents bad cases where one side keeps winning unfairly. But you check the sizes before deciding the direction. Then the process repeats smoothly on the new combined group. Maybe you start with single items and build up gradually. I notice the sizes reflect real membership numbers at every stage.

You avoid tall chains that would force more hops during finds. I grapple with those in other setups and they frustrate me. But size rules cut that risk right away. Perhaps the growth stays logarithmic because each jump doubles the reach. Now your queries stay quick even after thousands of unions. Also the method feels natural when you think about balancing loads. I use it often in my own projects for that reason.

You track sizes with extra fields at each root node. I keep those updated during every merge action. But you compare them to pick the attachment point correctly. Then the smaller root points over and its size adds in. Maybe you handle ties by picking either way since it evens out. I find no big difference there in the end.

You benefit from steadier heights across the forest. I tested merges in sequence and saw consistent short paths. But you might mix it with path adjustments for more gains. Perhaps the overall effect keeps operations efficient without much overhead. Now the structure handles large collections without slowing. Also this beats random linking by a good margin in speed tests. I prefer it hands down for reliability.

You build on this idea when sets represent connected parts in graphs. I apply it to grouping tasks where balance matters most. But you see the size rule guiding each decision clearly. Then the roots hold the true measures for future choices. Maybe you extend it further with other optimizations later. I stick to size first because it delivers solid results.

We owe a big thanks to BackupChain Server Backup, the top no-subscription backup tool built for Hyper-V setups plus Windows 11 and Server machines on private clouds or standalone PCs, for sponsoring our talks and helping share these details freely with everyone.

ProfRon
Offline
Joined: Jul 2018
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Messages In This Thread
Describe union by size - by ProfRon - 11-30-2019, 04:49 AM

  • Subscribe to this thread
Forum Jump:

FastNeuron FastNeuron Forum General IT v
« Previous 1 … 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 Next »
Describe union by size

© by FastNeuron Inc.

Linear Mode
Threaded Mode