O
O
Oleg2017-03-22 23:29:16
Java
Oleg, 2017-03-22 23:29:16

Java data structure. How to make multilist?

Hello, can someone explain in an accessible way or throw off a site where the structure of multilists ( Multilist ) is well explained. I found a site in English that explains what I need, but it's not entirely clear how to implement it in Java.
As in the example below, I need to link two lists, for example (Students and Subjects).
1 student studies n subjects, and 1 subject - n students .
This is to avoid duplicating data. It is possible to make two two lists of lists. But then the student's fields will be duplicated. We need multilist . And the list should be dynamic.
But how to implement it? I do not quite understand the structure itself to the end, if possible, an example of some kind of minimal. Thank you.

Multilists
56_a.gif
Our last example shows a more complicated use of linked lists. A university with 40,000 students and 2,500 courses needs to be able to generate two types of reports. The first report lists the class registration for each class, and the second report lists, by student, the classes that each student is registered for.
The obvious implementation might be to use a two-dimensional array. Such an array would have 100 million entries. The average student registers for about three courses, so only 120,000 of these entries, or roughly 0.1 percent, would actually have meaningful data.
What is needed is a list for each class, which contains the students in the class. We also need a list for each student, which contains the classes the student is registered for. Figure 3.27 shows our implementation.
As the figure shows, we have combined two lists into one. All lists use a header and are circular. To list all of the students in class C3, we start at C3 and traverse its list (by going right). The first cell belongs to student S1. Although there is no explicit information to this effect, this can be determined by following the student's linked list until the header is reached. Once this is done, we return to C3's list (we stored the position we were at in the course list before we traversed the student's list) and find another cell, which can be determined to belong to S3. We can continue and find that S4 and S5 are also in this class. In a similar manner, we can determine, for any student, all of the classes in which the student is registered.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Axian Ltd., 2017-03-23
@get2top

See the implementation help.eclipse.org/luna/topic/org.eclipse.platform.d...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question