Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help to write a program that uses a linked list based data structure for

ID: 3637885 • Letter: I

Question

I need help to write a program that uses a linked list based data structure for representing friendship relationships among persons specified by their names as strings.
1. define the linked list based, application support data structure and populate it from a text file. Each line contains person's name followed by the names of hi friends using comas as separators.
2. determine and display the person with most friends along with his friends. use a method maxFriends for determining the person with the most friends:

example of input file:
jeff, antonio, bobby, bill
jack, ivy, carla

in this example jeff has 3 friends and jack has only 2. therefore, jeff has more friends.

Thanks in advanced,

Explanation / Answer

some tips to get you started on this assignment are to first create a scanner that parses through the text file. If you're allowed to and if it makes things more clear for you, you can store each name you come across in an auxiliary structure (a stack, array, queue, etc...) Otherwise as you parse through each token in the name it appears as though the name will then include a comma, in order to get rid of that comma create a new temporary string and assign to it a substring of the name including the comma but with the ending parameter of the substring being length-1. Then create your a linkedlist node. If your node has just two fields; one for storing a string of the name, and one for storing a link to the next node, then assign to the first field the name and to the next field assign another node that way it points to another node. Do this until you reach the end of the array or stack or whatever you chose initially. Actually I forgot to mention that you'll want to create two scanners, one for parsing through each name within a line and one for parsing each line within the text. After you have created each linked list create a integer counter set at 0. Then create a temporary node called temp or current and while(current.next!=null) increment the counter and set current = current.next. after you do this you can compare the counters and see which yields the highest result and print the name field of the first node in the linked list that won. hope this helps i know it's very confusing but there are multiple ways to approach this problem!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote