please use python and I hope the code will be clear , make sure the answer same the output sample
Posted: Sun Jul 03, 2022 11:22 am
please use python and I hope the code will be clear , make sure the answer same the output sample
Example: The following figure shows a Queue whose nodes contains an integer value. Enqueuing the elements occur at the end and dequeuing elements occur at the beginning. This space is accessible 1 3 4 5 6 7 8 front Linear Queue Lab Exercise: Implement the following classes: 1. class course that includes two instance variables: id #course id Common Mistakes: Trying to directly access an element from the middle of the queue. The Cecular queue course name Your class should have the following: • A constructor that initializes the two instance variables id and • Set and get methods for each instance variable. deptName deptQueue MAXSize head 2. class DepartmentQueue (using the circular queue approach) that includes five instance variables: department name Department Queue maximum size of the queue Queue head
Your class should have the following: a constructor that initializes the department name exist (id) that checks whether the course object with id passed as parameter exists in the queue or not. enqueue (id, name) that creates and adds the course if the course with id passed as parameter does not exist in the enqueue. The course must be added to the top. Then return: o 1: if the insert was successful . ● ● 2: if the enqueue is full 3 if the value is a duplicate enqueue (temp) that inserts a node given as a parameter at the end of the queue. dequeue () removes and returns the first Node of the queue if the queue is not empty; otherwise, returns None. . findCourse (id) that returns a course name if the id exists in the queue otherwise, return None. print () that prints the department name and all the courses in the queue. . . o o
Write the expected time and space complexity as a comment at the beginning of each method of your class. 3. Write a test program named Lab3Test. Do the following: • Input the department name then create a department object. • Display a menu to the user asking for a choice to be entered. (see the sample output) • The program will perform the action selected by the user and display a proper message when necessary. • The program will repeat these actions until the user terminates the program (Hint: Use a loop).
Sample Output: Please enter the department name: Computer Engineering How many courses does the department have? 4 This program can perform the following 1- enqueue a course 2 dequeue a course - 3 search for a course 4 print queue 5 exit Please enter your selection: 4 Computer Engineering does not have any courses. This program can perform the following 1- 2- 3 4. enqueue a course dequeue a course search for a course print queue 5 exit Please enter your selection: 1 Enter the course number or -1 to stop: 325 Enter the course name: Human-Computer Interaction Enter the course number or -1 to stop: 262 Enter the course name: Digital Logic Enter the course number or -1 to stop: 207 Enter the course name: Data Structures Enter the course number or -1 to stop: 262 Enter the course name: testing duplicate Error! duplicate ID number... Enter the course number or -1 to stop: 221 Enter the course name: Software Engineering Enter the course number or -1 to stop: 200 Enter the course name: Testing Full The Department is full... The course could not be inserted.... 3 4 This program can perform the following 1 enqueue a course 2 dequeue a course search for a course print queue 5- exit Please enter your selection: 4 Courses in Computer Engineering department are: 1- 325 Human-Computer Interaction 2262 Digital Logic
3 4 207 Data Structures 221 Software Engineering This program can perform the following 1 enqueue a course 2 dequeue a course 3 search for a course 4 print queue 5 exit Please enter your selection: 3 Enter the course number: 207 The id: 207 corresponds to Data Structures This program can perform the following 1- enqueue a course dequeue a course search for a course print queue 2 3 4 5- exit Please enter your selection: 2 The course removed was 325 Human-Computer Interaction This program can perform the following 1- enqueue a course 2- dequeue a course 3 search for a course 4- print queue 5 exit Please enter your selection: 2 The course removed was 262 Digital Logic This program can perform the following 1- enqueue a course 2- dequeue a course 3- search for a course 4 print queue 5- exit Please enter your selection: 2 The course removed was 207 Data Structures This program can perform the following enqueue a course dequeue a course search for 1 2 3 course
4 5 - print queue - exit Please enter your selection: 3 Enter the course number: 207 The id: 207 does not correspond to any course in the department This program can perform the following 1- 2- 3- 4- 5 Please enter your selection: 2 2 enqueue a course dequeue a course I search for a course print queue exit The course removed was 221 Software Engineering This program can perform the following 1 enqueue a course dequeue a course search for a course 3 4- print queue 5 exit Please enter your selection: 2 The queue is empty! This program can perform the following 1- enqueue a course 2 dequeue a course 3- search for a course 4 print queue 5- exit Please enter your selection: S Exiting the programt
Example: The following figure shows a Queue whose nodes contains an integer value. Enqueuing the elements occur at the end and dequeuing elements occur at the beginning. This space is accessible 1 3 4 5 6 7 8 front Linear Queue Lab Exercise: Implement the following classes: 1. class course that includes two instance variables: id #course id Common Mistakes: Trying to directly access an element from the middle of the queue. The Cecular queue course name Your class should have the following: • A constructor that initializes the two instance variables id and • Set and get methods for each instance variable. deptName deptQueue MAXSize head 2. class DepartmentQueue (using the circular queue approach) that includes five instance variables: department name Department Queue maximum size of the queue Queue head
Your class should have the following: a constructor that initializes the department name exist (id) that checks whether the course object with id passed as parameter exists in the queue or not. enqueue (id, name) that creates and adds the course if the course with id passed as parameter does not exist in the enqueue. The course must be added to the top. Then return: o 1: if the insert was successful . ● ● 2: if the enqueue is full 3 if the value is a duplicate enqueue (temp) that inserts a node given as a parameter at the end of the queue. dequeue () removes and returns the first Node of the queue if the queue is not empty; otherwise, returns None. . findCourse (id) that returns a course name if the id exists in the queue otherwise, return None. print () that prints the department name and all the courses in the queue. . . o o
Write the expected time and space complexity as a comment at the beginning of each method of your class. 3. Write a test program named Lab3Test. Do the following: • Input the department name then create a department object. • Display a menu to the user asking for a choice to be entered. (see the sample output) • The program will perform the action selected by the user and display a proper message when necessary. • The program will repeat these actions until the user terminates the program (Hint: Use a loop).
Sample Output: Please enter the department name: Computer Engineering How many courses does the department have? 4 This program can perform the following 1- enqueue a course 2 dequeue a course - 3 search for a course 4 print queue 5 exit Please enter your selection: 4 Computer Engineering does not have any courses. This program can perform the following 1- 2- 3 4. enqueue a course dequeue a course search for a course print queue 5 exit Please enter your selection: 1 Enter the course number or -1 to stop: 325 Enter the course name: Human-Computer Interaction Enter the course number or -1 to stop: 262 Enter the course name: Digital Logic Enter the course number or -1 to stop: 207 Enter the course name: Data Structures Enter the course number or -1 to stop: 262 Enter the course name: testing duplicate Error! duplicate ID number... Enter the course number or -1 to stop: 221 Enter the course name: Software Engineering Enter the course number or -1 to stop: 200 Enter the course name: Testing Full The Department is full... The course could not be inserted.... 3 4 This program can perform the following 1 enqueue a course 2 dequeue a course search for a course print queue 5- exit Please enter your selection: 4 Courses in Computer Engineering department are: 1- 325 Human-Computer Interaction 2262 Digital Logic
3 4 207 Data Structures 221 Software Engineering This program can perform the following 1 enqueue a course 2 dequeue a course 3 search for a course 4 print queue 5 exit Please enter your selection: 3 Enter the course number: 207 The id: 207 corresponds to Data Structures This program can perform the following 1- enqueue a course dequeue a course search for a course print queue 2 3 4 5- exit Please enter your selection: 2 The course removed was 325 Human-Computer Interaction This program can perform the following 1- enqueue a course 2- dequeue a course 3 search for a course 4- print queue 5 exit Please enter your selection: 2 The course removed was 262 Digital Logic This program can perform the following 1- enqueue a course 2- dequeue a course 3- search for a course 4 print queue 5- exit Please enter your selection: 2 The course removed was 207 Data Structures This program can perform the following enqueue a course dequeue a course search for 1 2 3 course
4 5 - print queue - exit Please enter your selection: 3 Enter the course number: 207 The id: 207 does not correspond to any course in the department This program can perform the following 1- 2- 3- 4- 5 Please enter your selection: 2 2 enqueue a course dequeue a course I search for a course print queue exit The course removed was 221 Software Engineering This program can perform the following 1 enqueue a course dequeue a course search for a course 3 4- print queue 5 exit Please enter your selection: 2 The queue is empty! This program can perform the following 1- enqueue a course 2 dequeue a course 3- search for a course 4 print queue 5- exit Please enter your selection: S Exiting the programt