Objectives: 1. To be able to create and manipulate Queues. 2. To understand how to use Queues to simulate real-life prob

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Objectives: 1. To be able to create and manipulate Queues. 2. To understand how to use Queues to simulate real-life prob

Post by answerhappygod »

Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 1
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 1 (43.75 KiB) Viewed 32 times
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 2
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 2 (43.75 KiB) Viewed 32 times
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 3
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 3 (36.29 KiB) Viewed 32 times
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 4
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 4 (41.47 KiB) Viewed 32 times
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 5
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 5 (34.19 KiB) Viewed 32 times
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 6
Objectives 1 To Be Able To Create And Manipulate Queues 2 To Understand How To Use Queues To Simulate Real Life Prob 6 (33.57 KiB) Viewed 32 times
Objectives: 1. To be able to create and manipulate Queues. 2. To understand how to use Queues to simulate real-life problems Background: A Queue is a linear data structure that implements a First In First Out (FIFO) add/remove policy. This is equivalent to the requirement that once an element is added, all elements that were added before have to be removed before the new element can be taken out. A Queue is characterized by two fundamental operations, called enqueue and dequeue. The enqueue operation adds a new item to the end of the Queue or initializes the Queue if it is empty. The dequeue operation removes an item from the beginning of the queue. A dequeue either reveals previously concealed item or results in an empty queue. The queue pointers are the reference to the beginning (head) and end (tail) values in the queue. Lab: Queues 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 inaccessible Į 3 front Linear Queue 7 8 rear rear 8 This space can be utilized Circular queue Common Mistakes: Trying to directly access an element from the middle of the queue. front
Lab Exercise: Implement the following classes: 1. class course that includes two instance variables: course id id name #course name Your class should have the following: A constructor that initializes the two instance variables sd and name. • Set and get methods for each instance variable. 2. class DepartmentQueue (using the circular queue approach) that includes five instance variables: deptane deptQueue maxSize head tail department name Department Quee maximum size of the queue Queve head Que tall 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 o 2: if the enqueue is full o 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. 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 enqueue a course 1 2 3 4 5 exit Please enter your selection: 4 Computer Engineering does not have any courses. This program can perform the following 1 enqueue a course 2 3 4 dequeue a course search for a course print queue 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... This program can perform the following enqueue a course 1 2 dequeue a course 3 search for a course 4 print queue 5 exit Please enter your selection: 4 Courses in Computer Engineering department are: 1- 325 Human-Computer Interaction 2- 262 Digital Logic
3- 207 Data Structures 4 221 Software Engineering This program can perform the following enqueue a course dequeue a course search for a course print queue 1 2 3 4 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 enqueue a course dequeue a course search for a course print queue exit 1 2 3 4 5 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 3 dequeue a course search for a course print queue 4 5 exit Please enter your selection: 2 The course removed was 287 Data Structures 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 does not correspond to any course in the department This program can perform the following enqueue a course. dequeue a course search for a course 1 2 3 4 5 exit Please enter your selection: 2 The course removed was 221 Software Engineering This program can perform the following 1 enqueue a course 2 3 print queue 1 2 3 dequeue a course search for a course print queue exit 4 5 Please enter your selection: 2 The queue is empty! This program can perform the following enqueue a course. dequeue a course search for a course. 4 print queue 5 - exit Please enter your selection: 5 Exiting the program!
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply