I have to create a star shape (like a star topology in networking) with nodes in java for homework and I'm not sure which data structure to use. There should be a central node with periheral nodes pointing to it that are not linked directly to each other but are all linked through the central node. I am to achieve this using three classes apart from the class with the main method. I'm thinking a linked list or a stack or queue would not accomplish this since they all have a particular order which I don't know how to manipulate (but they're all I've been taught about thus far). Any suggestions or links or comments on where I could begin would be very appreciated!
Asked
Active
Viewed 146 times
1 Answers
0
I think in your case you need just to use Graph data structure, or to be more specific, if you are sure that you just need one node to be connected to all other nodes, you can use Tree. Finally I think you need to look how to implement those data structures in JAVA, so look at this:
https://www.geeksforgeeks.org/graph-and-its-representations/

Ismail
- 2,322
- 1
- 12
- 26