Suppose you are developing a program that frequently tests w

Suppose you are developing a program that frequently tests whether a student is in a soccer team, what is the best data structure to store the students in a soccer team? Justify your answer.

Solution

Suppose we are developing a program that frequently tests whether a student is in a soccer team.

The best data structure to store the students in a soccer team is HashSet.

Because its complexity is O(1) so when number of students(n) will increase it not effects the program complexity and set is a collection that contains no duplicate elements while if you use ArrayList or LinkedList then it can store duplicate value that is not good for program and TreeSet complexity is O(log n) which is not batter then HashSet.

Suppose you are developing a program that frequently tests whether a student is in a soccer team, what is the best data structure to store the students in a soc

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site