Home / Expert Answers / Computer Science / data-structure-and-algorithm-problem-2-student-message-transfer-line-there-is-a-list-of-30-students-pa246

(Solved): Data structure and algorithm Problem 2: Student message transfer line There is a list of 30 students ...



Data structure and algorithm

student submitted image, transcription available below
Problem 2: Student message transfer line There is a list of 30 students, the names of which are read from \\( D \\) : \\class2.txt. Each student in a line can pass a message (a string) to any other student after or before him/her (depending on the current direction of the message). This message is received from the user at the beginning and also when the message arrives to a hub student. Hub students are randomly chosen and the number of them is received from the user before starting the program. As the first move, a student and a direction (left or right) is randomly chosen. The message (a string received from the user) moves in this direction until it reaches a hub student or it reaches the end of the list (the last of first student). So, the moving direction will be switched only when the message reaches to a hub or to the border (first/last) students. When a message arrives to a student, it can pass this message to another student that is placed in the kth (a random number between 1 and 5) position next (right) or previous (left) to him/her. Each student in the message line can only pass the message to one student in forward or backward directions. However, if the message arrives at a hub-student, he/she reset the message by asking a new message from the user and also changes the moving direction, i.e, if the message was already moving forward, it will move backward vice versa. You will write a program to simulate this scenario where the student message line is modelled as a doubly linked list. You must create appropriate container (Node) class to include Students. a) The list is generated randomly with 30 students. b) Names should be read from a txt file, e.g. D:\\class2.txt c) M students will be chosen randomly as hub-student. The value of M will be received from the user. d) The direction of message transfer is selected randomly either as forward or backwards at the beginning. Once the direction is set, it does not change until message arrives to a hub student or the first or last student. e) Your code should record the number of letters that each student has in common with all messages visited by him/her. For example, if student name is \"ali\" and he has visited the following messages: \"Selam\", \"Merhaba\", \"Isik\", the output for this student at the end of program should be 5, because \"la\", two \" \\( \\mathrm{a} \\) \"s, and one \" \\( \\mathrm{i} \\) \" from those messages exist in \"ali\". f) The program will end when all students have been visited at least one time. g) The program is case-sensitive, i.e., ' \\( A \\) ' is not the same as ' \\( a \\) '. h) The program may have the following interface. You are free to change the interfac


We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe