Implement  changeArrayLength(int m) – void method; 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 void changeArrayLength(int m) {         // insert your solution here     }   This method creates a new student table for this course; this new table has the given length m; the method moves all registered students to this table, as described in more detail below. Note that this method itself does not move the waitlisted students. This method creates a new array of SLinkedList, moves all the registered students into these linked lists, and changes this course’s studentTable field so it references this new table instead. Each student in the current table will be moved to the new table. This will require in most cases that the student is moved to a different array slot index. The slot index for the SLinkedList that they are moved to is id % m, where m is the new length of the array (the parameter of the method). The motivation for increasing the capacity of the array is that it keeps the average lengths of the linkedlists below 1, which tends to mean a fast traversal of each linked list.  ** I already have public class Student and public SLinkedList defined **

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Implement  changeArrayLength(int m) – void method;

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 void changeArrayLength(int m) {
        // insert your solution here
    }

 

This method creates a new student table for this course; this new table has the given length m; the method moves all registered students to this table, as described in more detail below. Note that this method itself does not move the waitlisted students. This method creates a new array of SLinkedList, moves all the registered students into these linked lists, and changes this course’s studentTable field so it references this new table instead. Each student in the current table will be moved to the new table. This will require in most cases that the student is moved to a different array slot index. The slot index for the SLinkedList that they are moved to is id % m, where m is the new length of the array (the parameter of the method). The motivation for increasing the capacity of the array is that it keeps the average lengths of the linkedlists below 1, which tends to mean a fast traversal of each linked list. 

** I already have public class Student and public SLinkedList defined **

 

id % m
Yingzi
Héctor
Giulia
15
25
Course.java
1
String code: "COMP250"
int capacity: 5
LL[] studentTable
Kavosh
13
3
Rahul
int size: 5
3
LL waitlist
4
Ria
Sasha
21
33
Yingzi
Héctor
Giulia
Kavosh
Rahul
5
15
25
13
3
Transcribed Image Text:id % m Yingzi Héctor Giulia 15 25 Course.java 1 String code: "COMP250" int capacity: 5 LL[] studentTable Kavosh 13 3 Rahul int size: 5 3 LL waitlist 4 Ria Sasha 21 33 Yingzi Héctor Giulia Kavosh Rahul 5 15 25 13 3
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY