Implement solution for remove(int id) removes the Student associated with this id; if the id is not found in the table or on the waitlist, then it should return null; otherwise, it should return the Student associated with the id. If the student that is removed was registered, then this student should be replaced by the student who is first in the waitlist queue. If the student who is removed was on the waitlist, then they should just be removed from the waitlist. You should go directly to slot id % m rather than iterating through all the slots. public class Course { public String code; public int capacity; public SLinkedList[] studentTable; public int size; public SLinkedList waitlist; public Course(String code) { this.code = code; this.studentTable = new SLinkedList[10]; this.size = 0; this.waitlist = new SLinkedList(); this.capacity = 10; } public Course(String code, int capacity) { this.code = code; this.studentTable = new SLinkedList[capacity]; this.size = 0; this.waitlist = new SLinkedList<>(); this.capacity = capacity; } public int getCourseSize() { // insert your solution here and modify the return statement return -1; }
Implement solution for remove(int id)
removes the Student associated with this id; if the id is not found in the table or on the waitlist, then it should return null; otherwise, it should return the Student associated with the id. If the student that is removed was registered, then this student should be replaced by the student who is first in the waitlist queue. If the student who is removed was on the waitlist, then they should just be removed from the waitlist. You should go directly to slot id % m rather than iterating through all the slots.
public class Course {
public String code;
public int capacity;
public SLinkedList<Student>[] studentTable;
public int size;
public SLinkedList<Student> waitlist;
public Course(String code) {
this.code = code;
this.studentTable = new SLinkedList[10];
this.size = 0;
this.waitlist = new SLinkedList<Student>();
this.capacity = 10;
}
public Course(String code, int capacity) {
this.code = code;
this.studentTable = new SLinkedList[capacity];
this.size = 0;
this.waitlist = new SLinkedList<>();
this.capacity = capacity;
}
public int getCourseSize() {
// insert your solution here and modify the return statement
return -1;
}
![1 public class Course {
public String code;
public int capacity;
public SLinkedList<Student> [] studentTable;
public int size;
public SLinkedList<Student> waitlist;
4
5
6.
7
8
public Course(String code) {
this.code = code;
this.studentTable = new SLinkedList[10];
this.size = 0;
this.waitlist = new SLinkedList<Student>();
this.capacity
}
10
11
12
13
14
= 10;
15
16
public Course(String code, int capacity) {
this.code = code;
this.studentTable = new SLinkedList[capacity];
this.size = 0;
this.waitlist = new SLinkedList<>();
this.capacity = capacity;
}
17e
18
19
20
21
22
23
24
O 250
虽26
® 27
O 28
29
public void changeArrayLength(int m) {
public SLinkedList<Student>[] newStudentTable;
for (int i = 0; i < m; i++) {
newStudentTable[i] = new SLinkedList<Student>;
}
30
O 31
for (int i = 0; i < studentTable. length; i++) {
for (int j = 0; j < studentTable[i].size(); j++) {
int tempIndex = studentTable[i].get(j). getId() % m;
newStudentTable[tempIndex].add (studentTable[i].get(j));
}
}
32
A 33
x 34
35
36
37
38
studentTable = newStudentTable;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9c002e4e-ece1-4dd1-9934-cbb442392244%2Fecdae64b-291a-4c78-9b72-6bd15bb0b99c%2Fh3dt00e_processed.png&w=3840&q=75)
![Student.java
oublic class Student {
public int id;
public String name;
public SLinkedList<String> courseCodes;
public final int COURSE_CAP
3;
%3D
public Student(int id, String name) {
this.id = id;
this.name = name;
this.courseCodes = new SLinkedList<String>();
}
public boolean isRegistered0rWaitlisted (String course) {
return this.courseCodes.getIndex0f(course) > -1;
}
public void addCourse(String course) {
this.courseCodes.addLast(course);
}
public void dropCourse(String course) {
this.courseCodes.remove(course);
}
public String toString(){
return "#" + this.id +
: " + this.name;
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9c002e4e-ece1-4dd1-9934-cbb442392244%2Fecdae64b-291a-4c78-9b72-6bd15bb0b99c%2Fj4fx5y_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)