Write three classes: Student.java, StudentList.java and Course.java with using the concept of linked list.
import java.util.HashMap; import java.util.Objects; public class StudentList { private HashMap<Student, CourseList> studentList; public StudentList() { this.studentList = new HashMap<>(); } public void add(Student student, Course course) { if (this.studentList.containsKey(student)) { CourseList courseListOfStudent = studentList.get(student); courseListOfStudent.add(course); return; } CourseList courseList = new CourseList(); courseList.add(course); studentList.put(student, courseList); } public void display() { for (Student student : studentList.keySet()) { System.out.println("Student Name ::" + student); studentList.get(student).courseList(); System.out.println(); } } public static void main(String[] args) { StudentList studentList = new StudentList(); studentList.add(new Student("srinu"),new Course("MATHS")); studentList.add(new Student("srinu"),new Course("Physics")); studentList.add(new Student("srinu"),new Course("IT")); studentList.add(new Student("ram"),new Course("MATHS")); studentList.add(new Student("ram"),new Course("Chemistry")); studentList.add(new Student("John"),new Course("IT")); studentList.display(); } } class Course { private final String courseName; public Course(String courseName) { this.courseName = courseName; } @Override public String toString() { return courseName; } } class Student { private final String name; public Student(String name) { this.name = name; } @Override public String toString() { return name; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Student student = (Student) o; return Objects.equals(name, student.name); } @Override public int hashCode() { return Objects.hash(name); } } class CourseList { private Node head; public CourseList() { this.head = null; } public void add(Course course) { if (head == null) { head = new Node(course); return; } Node temp = new Node(course); temp.next = head; head = temp; } public void courseList() { System.out.printf("Course List:: "); Node temp = head; while (temp != null) { System.out.printf("%s ", temp.getCourse()); temp = temp.next; } System.out.println(); } } class Node { private Course course; Node next; public Node(Course course) { this.course = course; this.next = null; } public Course getCourse() { return course; } } |
![]() |
Write three classes: Student.java, StudentList.java and Course.java with using the concept of linked list.
Using a class template, write a linked list with 5 nodes and print the linked list. Then make a second linked list with the values from the first linked list and reverse the values and print. (C++)
Can someone write an example of a Linked list code that simply adds items to the head and to the tail of the list in PYTHON while using classes.
Using the concept of singly linked list, show all the pointer updates required for the following Operation (show steps hy using starting 6 chancters of your full name): head 10.pico, Bormes R
each A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a term of the polynomial. The polynomial 4X-3X-5 would be represented as the linked list. as the linked list the polnomial eql -5 0 Write a program system that reads two polynomials, stores them as linked lists, adds them together, and prints the result as a polynomial. The result should be a third linked list. Hint: Travers both polynomials. If a...
C# please Write method to search a node in linked list using ID recursively, Write method to search a node in linked list using NAME recursively
write a java program implementing stacks using arrays. (not with linked list)
Write a C++ program to manage a list of inventory items using a linked list. Operations should include adding a new inventory item at the end of the list, adding a new inventory item at the beginning of the list, removing an inventory item from the beginning of the list, removing an inventory item from the end of the list, removing an inventory item by name, and display the current list of inventory items. Allow the user an option to...
Explain the concept of Linked hash table and Write a program in C# where you implement the concept of linked hash table
List the three major classes of carbohydrates and give a specific example of each. 2. Write the reaction (using words, not formulas) for the hydrolysis of sucrose. 3. Cellulose and amylose are both polysaccharides. What specific test can be used to differentiate between the two compounds? 4. What is the definition of a reducing sugar? 5. What purpose does the control test tube of water serve for the carbohydrate tests? Reminder: there is one more problem on the next page]
Java - Write an insertBefore method for a List implemented as a Linked List that contains two dummy nodes. - Write an insertAfter method for a List implemented as a Linked List that contains two dummy nodes.