Design a course registry that manages instructors, courses, and the teaching assignment between them. Instructors and courses are created independently: an instructor may teach no courses, and a course may remain unassigned.
The provided CourseRegistry class supports these operations:
CourseRegistry() creates a registry with no instructors and no courses.boolean addInstructor(String name) adds an instructor and returns true. A name already present is refused with false.boolean addCourse(String title) adds a course and returns true. A title already present is refused with false.boolean assign(String title, String instructorName) assigns the course to the instructor and returns true. If either one does not exist, it changes nothing and returns false. Assigning an already assigned course replaces its previous instructor.String instructorOf(String title) returns the name of the instructor teaching that course, or "NONE" when the course has none or does not exist.String[] coursesOf(String instructorName) returns the titles that instructor teaches, in the order the courses were added.int courseCount() returns how many courses exist.Each course can reference at most one instructor, while an instructor may teach many courses. The relationship is an association: replacing or removing the link would not destroy either object.
Your task is to implement the Instructor and Course classes expected by the provided registry. Do not modify CourseRegistry. Store the teaching assignment as a reference from Course to Instructor, not as a copied instructor name.
Input:
Output:
Explanation: Ada and LLD are created independently, then assign links the course to the instructor object. instructorOf("LLD") follows that link to Ada, while coursesOf("Ada") finds LLD by reading the same association in reverse.
Input:
Output:
Explanation: DSA exists even though it has no instructor, so instructorOf("DSA") returns "NONE". Assigning it to an instructor who was never added fails without changing the course.
1 <= name.length <= 40 and 1 <= title.length <= 40100 calls will be made across all methods.Full marks when instructors and courses are separate types created independently of each other, and the link between them is a reference held by one of them rather than a pair of names matched later. Lose points when a course stores the instructor's name as a string, or when the two are collapsed into one type.
Full marks when adding an instructor and adding a course neither require nor create the other, and an unlinked course is a normal state rather than an error. Lose points when a course cannot exist without an instructor, or when assigning creates a missing instructor without being asked to.
Full marks when the registry looks each side up in one place, reassignment replaces the previous link, and coursesOf reports courses in the order they were added. Lose points for duplicated lookup code, for sorting the result, or for printing to stdout.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new CourseRegistry() | null |
| addInstructor("Ada") | true |
| addCourse("LLD") | true |
| assign("LLD", "Ada") | true |
| instructorOf("LLD") | "Ada" |
| coursesOf("Ada") | ["LLD"] |
An instructor and a course are added independently, then linked. The link reads the same from either end.
Run checks these cases. Submit also runs a larger hidden set.

