• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

More efficient linked data structures?

gregulator

Senior member
Okay so I am programming in java and am making a set class that does not need to be sorted but the user needs to be able to insert integers, see if an integer is present, intersec and union the sets. I am wondering if there is a better way to do some of the operations I need to do, because right now, my code is kind of messy and inefficient. I can only use a linear link, no trees or double links or anything. I would like to know if there is a better way to search for an integer in the list rather than going through the list link by link and checking the data stored in each node. The way I have the class set up is that set is one object, and nodes are another so that the set object can point to the "head" of a bunch of linked nodes. This becomes a big problem when intersecting sets because if i have sets A and B, for each node in A, i have to go through the entire list of nodes in B, comparing the data. Thanks for any help, I am just trying to think of a better way to do this but i might just have to use some other data structure.
 
Back
Top