Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

passing 2D collection objects into 1D collection objects

when, where, how, why we need to passing 2D collection objects like hashmap, hashtable, properties into 1D collection objects like arraylist, vector, hasset, sorted set etc  and reading back again. What are the practical uses, advantages, disadvanages of doing it.Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of sweetfa2
sweetfa2
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

>>Sometimes you can do this sort of thing to rebalance a TreeMap or something similar where aver time the tree becomes unbalanced because a lot of work is happening on a few node groups.


can you please elaborate on above point. I am not clear on that.
Think of a tree as a set of roots for a tree.

As things get added to the tree they get added to one side or the other of the tree depending on where they fall between the existing nodes.  If you delete a lot of nodes from one side of the tree roots, then it is like cutting of one set of branches of a tree.  The tree no longer has the same number of nodes (branches/root branches) evenly spaced over a tree.

A similar thing happens when lots of additions occur between the keys that sit on one side of the tree.  That side of the tree becomes unbalanced and a tree search needs to descend further nodes to find the correct key value.  This slows down the performance of a tree.

Most tree algorithms will have a capacity to rebalance, some automatically, some manually to adjust the nodes of the tree back to something approximating equality.