Concept explainers
Using pseudocode similar to the Java class syntax of Figure 8.27, sketch a definition of an abstract data type representing a queue. Then give pseudocode statements showing how instances of that type could be created and how entries could be inserted in and deleted from those instances.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Computer Science: An Overview (12th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (8th Edition)
Degarmo's Materials And Processes In Manufacturing
Starting Out with C++ from Control Structures to Objects (9th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
- d. In implementing a Queue using an array, a problem might arise if the Queue is implemented in such a way that items in the Queue are inserted at the next available location and removed from the next leading position, but such that, once deleted, the emptied space is unused. The problem that arises is one where there is free space still in the array, but it is not usable because it is not at the end. Demonstrate this problem with a Queue that is stored in an array of size 5 for the following instructions. Next, explain how you might resolve this problem. Queue q constructor takes 5 as the size of the array = new Queue(5); // assume the Queue q.enqueue(3); q.enqueue(4); q.enqueue(1); q.dequeue( ); q.dequeue( ); q.enqueue(6); q.enqueue(5); q.dequeue( ); // at this point, // there are only 2 item2 in the queue q.enqueue(7); // this enqueue can not occur, why??arrow_forwardAnswer the given question with a proper explanation and step-by-step solution. write the program in Javaarrow_forwardIn a programming language (Pascal), the declaration of a node in a singly linked list is shown in Figure P6.7(a). The list referred to for the problem is shown in Figure P6.7(b). Given P to be a pointer to a node, the instructions DATA(P) and LINK(P) referring to the DATA and LINK fields, respectively, of node P are equivalently represented by P↑. DATA and P↑. LINK in the programming language. What do the following commands do to the logical representation of the list T? i) ii) TYPE POINTER=NODE; NODE RECORD DATA: integer; LINK: POINTER END; VAR P, Q R: T POINTER (a) Declaration of a node in a singly linked list T 31 TE 57 12 (b) A singly linked list T iii) R₁.LINK: = Q iv) R₁.DATA: = P₁.DATA: Q₁.DATA + R₁.DATA Q: = P |R Figure P6.7. (a and b) Declaration of a node in a programming language and the logical representation of a singly linked list T Q.LINK.DATA + 10 91 Linked Lists 189arrow_forward
- you are to design a printer queue that is responsible for handling the printing requests coming from different users. You have to take into consideration that users have different levels of priorities. Each user has an identification number and a password, in addition to printing priorities. One good idea is to design the queue using an array or pointers while preserving the first-in first-out concept of the queue. For every printing request received, the program should check the priorities of that request and whether it can be moved forward in the queue to be served by the printer prior to serving the other requests. Using the programming language of your choice (preferably C++), write the printer queue that would handle the user request. The program must allow for requests coming from different users or from one user. Note: I need a working C++ code for this problem, and i need priorities.arrow_forwardJAVA CODEarrow_forwardWrite an abstract data type for queues whose elements store 10-characternames. The queue elements must be dynamically allocated from theheap. Queue operations are enqueue, dequeue, and empty. Use eitherC++, Java, C#, or Rubyarrow_forward
- Assume that a queue is implemented in C programming language using an array with size 15. At some point the front is at index 9 and rear (the last element) is 14. If an element is dequeued, front and rear indexes are: a) Front:9 Rear:15 b) Front:9 Rear: 0 c) Front:10 Rear: 0 d) Front:10 Rear:14arrow_forwardThis is a java data structures question - Given a circular bent array-based queue capable of holding 100 objects. Suppose the queue is initially empty, and then objects are put into the queue at the rate of 10 per minute while meantime they are processed and removed from the queue at the rate of 5 per minute. After 120 elements have been added to the queue, which of the following is true? CIRCLE JUST ONE LETTER FOR THE ANSWER. -> You can’t add 120 elements to an array holding 100 entries. -> There will be 60 elements in the queue, 20 of them at the front of the array where the queue started, and 40 at the other end. -> There will be 60 elements in the queue, 30 of them at the front of the array where the queue started, and 30 at the other end. -> There will be 60 elements in the queue, 40 of them at the front of the array where the queue started, and 20 at the other end.arrow_forwardIn C++, develop an algorithm that adds the value val to a queue object Q. The queue is represented using an array data of size s. The algorithm should assume that the queue is not full. The most recently added item is at index r (rear), and the least recently added item is at index f (front). If the queue is empty, r = f = -1.arrow_forward
- Done in python, Thanks in advance.arrow_forwardThe Min-priority Queue is an abstract data type (ADT) for maintaining a collection of elements,each with an associated value called a key. The ADT supports the following operations:• INSERT(Q,x): insert the element x into the queue Q.• MIN(Q): returns the element of Q with the smallest key.• EXTRACT-MIN (Q): removes and returns the element of Q with the smallest key.Implement in Java the Min-priority Queue ADT defined above using a) an array based binary heap b) a binary search tree. Observe that the ADT implementation operations should be in the form q.insert(x),q.min(), etc. Explain in the report your implementation, noting the running time (using bigOh notation) of each operation in both implementations. c) What are the worst-case running times of the three ADT operations when theunderlying BST is self-balancing? Briefly explain your answer. d) Implement an extension of BST that allows MIN and EXTRACT-MIN operations in O(1). Briefly describe your implementation in the report. Hint:…arrow_forwardin python Provide python code and screenshotarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education