Computer Science: An Overview (13th Edition) (What's New in Computer Science)
13th Edition
ISBN: 9780134875460
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 8.1, Problem 4QE
Program Plan Intro
Queue:
It is a list in which the entries are removed only at the head and new entries are inserted only at the tail. It is a first in first out process.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Queues are often used to simulate situations where people have to wait in line. One scenario we can simulate with a queue is the annual Single’s Night dance at the Elks Lodge. Men and women enter the lodge and stand in line. The dance floor is quite small and there is room for only three couples at a time. As there is room on the dance floor, dance partners are chosen by taking the first man and woman in line. These couples are taken out of the queue and the next set of men and women are moved to the front of the queue.
As this action takes place, the program announces the first set of dance partners and who the next people are in line. If there is not a complete couple, the next person in line is announced. If no one is left in line, this fact is displayed.First, let’s look at the data we use for the simulation:F Jennifer IngramM Frank OpitzM Terrill BeckermanM Mike DahlyF Beata LovelaceM Raymond WilliamsF Shirley YawM Don GundolfF Bernica TackettM David DurrM Mike McMillanF Nikki…
In a bank, customers wait in a queue (q0) for their turn to complete a transaction. Customers who come first are
served first. At a certain point when there are lots of customers waiting, a decision is taken to split the queue
elements into two empty queues q1 and q2. The customers are split based on the alphabetical order of their first
names. Customers with first name starting A-H are added to q1 while the others (first name starting I-Z) are
added to q2.
In an application, write a method named splitQueue (in an application) that accepts as parameters 3 queues, the
original queue (q0) and two empty queues (q1 and q2) to be filled as described above. Write also a main
method in which you read the first names of customers from the user, fill them into q0 and call the method
splitQueue to split q0 elements into q1 and q2. After the split display the elements of q1 first then those of q2.
The header of the method is:
public static void splitQueue ( Queue q0, Queue q1, Queue q2)
Note:…
Please help me with this!
During the Battle at the Alamo, a the defenders suddenly discovered they are surrounded by an overwhelming force. There is absolutely no hope for victory without reinforcements, and David Crockett's horse is the only horse available that can be used to escape and summon help. The defenders agree to a pact to determine which of them is to go for help.
The defenders form a queue and they pick a number from a hat. Beginning with the first officer in the queue, they begin to count. As each defender counts off, he moves to the end of the queue. When the count reaches the number that was picked, that defender is removed from the queue, and the count begins again with the next man. Once an defender is removed from the queue, he is no longer counted. The last defender that remains in the queue is the one that rides away on the horse to summon help.
——————————
The countOff() method displays the name of each officer removed from the queue, in the order in which they…
Chapter 8 Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Ch. 8.1 - Give examples (outside of computer science) of...Ch. 8.1 - Prob. 2QECh. 8.1 - Prob. 3QECh. 8.1 - Prob. 4QECh. 8.1 - Prob. 5QECh. 8.2 - In what sense are data structures such as arrays,...Ch. 8.2 - Prob. 2QECh. 8.2 - Prob. 3QECh. 8.3 - Prob. 1QECh. 8.3 - Prob. 2QE
Ch. 8.3 - Prob. 3QECh. 8.3 - Prob. 4QECh. 8.3 - Modify the function in Figure 8.19 so that it...Ch. 8.3 - Prob. 7QECh. 8.3 - Prob. 8QECh. 8.3 - Draw a diagram representing how the tree below...Ch. 8.4 - Prob. 1QECh. 8.4 - Prob. 2QECh. 8.4 - Prob. 3QECh. 8.4 - Prob. 4QECh. 8.5 - Prob. 1QECh. 8.5 - Prob. 3QECh. 8.5 - Prob. 4QECh. 8.6 - In what ways are abstract data types and classes...Ch. 8.6 - What is the difference between a class and an...Ch. 8.6 - Prob. 3QECh. 8.7 - Suppose the Vole machine language (Appendix C) has...Ch. 8.7 - Prob. 2QECh. 8.7 - Using the extensions described at the end of this...Ch. 8.7 - In the chapter, we introduced a machine...Ch. 8 - Prob. 1CRPCh. 8 - Prob. 2CRPCh. 8 - (Asterisked problems are associated with optional...Ch. 8 - Prob. 4CRPCh. 8 - (Asterisked problems are associated with optional...Ch. 8 - Prob. 6CRPCh. 8 - Prob. 7CRPCh. 8 - Prob. 8CRPCh. 8 - Prob. 9CRPCh. 8 - Prob. 10CRPCh. 8 - Prob. 11CRPCh. 8 - Prob. 12CRPCh. 8 - Prob. 13CRPCh. 8 - Prob. 14CRPCh. 8 - Prob. 15CRPCh. 8 - Prob. 16CRPCh. 8 - Prob. 17CRPCh. 8 - Prob. 18CRPCh. 8 - Design a function to compare the contents of two...Ch. 8 - (Asterisked problems are associated with optional...Ch. 8 - (Asterisked problems are associated with optional...Ch. 8 - Prob. 22CRPCh. 8 - Prob. 23CRPCh. 8 - Prob. 24CRPCh. 8 - (Asterisked problems are associated with optional...Ch. 8 - Prob. 26CRPCh. 8 - Prob. 27CRPCh. 8 - Prob. 28CRPCh. 8 - Prob. 29CRPCh. 8 - Prob. 30CRPCh. 8 - Design a nonrecursive algorithm to replace the...Ch. 8 - Prob. 32CRPCh. 8 - Prob. 33CRPCh. 8 - Prob. 34CRPCh. 8 - Draw a diagram showing how the binary tree below...Ch. 8 - Prob. 36CRPCh. 8 - Prob. 37CRPCh. 8 - Prob. 38CRPCh. 8 - Prob. 39CRPCh. 8 - Prob. 40CRPCh. 8 - Modify the function in Figure 8.24 print the list...Ch. 8 - Prob. 42CRPCh. 8 - Prob. 43CRPCh. 8 - Prob. 44CRPCh. 8 - Prob. 45CRPCh. 8 - Prob. 46CRPCh. 8 - Using pseudocode similar to the Java class syntax...Ch. 8 - Prob. 48CRPCh. 8 - Identify the data structures and procedures that...Ch. 8 - Prob. 51CRPCh. 8 - In what way is a class more general than a...Ch. 8 - Prob. 53CRPCh. 8 - Prob. 54CRPCh. 8 - Prob. 55CRPCh. 8 - Prob. 1SICh. 8 - Prob. 2SICh. 8 - In many application programs, the size to which a...Ch. 8 - Prob. 4SICh. 8 - Prob. 5SICh. 8 - Prob. 6SICh. 8 - Prob. 7SICh. 8 - Prob. 8SI
Knowledge Booster
Similar questions
- Suppose that you have circular queue with size 50.answer the following questions: 1- If the Front equals 40 and Rear equals 39, after adding one element to the queue (if it possible) what are the values of Front and Rear? 2- If the Front equals Rear which equals 35, how many elements in the queue then? 3- If the Front cquals 49 and Rear equals 5, after deleting two elements (if it possible) what are the values of front and Rear? 4- If the Rear equals 27 and Font equals 28, after adding one element (if it possible) what are the values of front and rear?arrow_forwardWrite a program to find second maximum value in liner queue.arrow_forwardSuppose the rule of the party is that the participants who arrive later will leave earlier. Which data structure is appropriate to store the participants? Stack Queue ArrayList Linked Listarrow_forward
- USING C LANGUAGE Use a queue to generate binary number strings. Hint: For example, enqueue "1" onto the queue. Then dequeue "1", print it, and place "10" and "11" on the queue (add "0" and "1" at the end of the printed item "1"). Dequeue "10", print it, and add "100" and "101" onto the queue, etc. Strings only may be used and you are allowed to use string.h. You can input n from the user and count from 1 to n in binary using the queue. Suppose you have an empty string and you want to print 1 to 9 binary numbers. Your code will generate the following output: 1 print 10 11 enque 0 and 1 10 print 100 101 enque 0 and 1 …. You can either choose an array implementation or a linked list implementation of the queue.arrow_forwardCould you give me an example of how waiting in queue works?arrow_forwardImplement solution for remove(int id) removes the Student associated with this id; if the id is not found in the table or on the waitlist, then it should return null; otherwise, it should return the Student associated with the id. If the student that is removed was registered, then this student should be replaced by the student who is first in the waitlist queue. If the student who is removed was on the waitlist, then they should just be removed from the waitlist. You should go directly to slot id % m rather than iterating through all the slots. 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…arrow_forward
- If a queue is empty, Select one: A.You can dequeue an element from the queue B.The size of the queue is 1 C.You cannot enqueue an element into the queue. D.You cannot dequeue an element from the queue.arrow_forwardA company "XYZ" is manufacturing two types of grinders, called X and Y. The grinders X and Y are kept in a row. Write an algorithm using the queue data structure to replace all grinders X in the row with grinder Y. Illustrate your algorithm for any sample input.arrow_forwardUsing only the algorithm in queue ADT . Write an Algorithm called catqueue that concatenates two queues together. The second Queue is to be put at the end of first Queue.arrow_forward
- You are approached by an online delivery shipping firm, which asks you to write them code for some tasks they face. The products they ship have some attributes, which are as follows: Product ID (Integer) [This is unique for every product] Product label (String) Manufacturer (String) All strings are of maximum length 100 and contain only alphanumeric characters. The products arrive one by one, and a common queue is maintained for all of them. Also, there is a fixed set of manufacturers the company has a tie-up with: Nike Adidas Reebok Puma Diadora You are to automate some repetitive tasks. The tasks are as follows: 1) Add a new product to the queue. 2) Deliver the next product of the queue and print the product information delivered. 3) Query how many products of a given manufacturer is currently present in the queue. 4) Query how many products of a given manufacturer has been shipped already. Initially, the product queue is empty. It is also guaranteed that when new products are…arrow_forwardWrite a program for the implementation of a queue using singly linked list. The elements of the queue should be strings of length at most 20 characters. Print the queue and do the following operations on the created queue : (a) Insert a new element. (b) Delete an element from the queue.arrow_forwardWrite a program using the queue in the Java language, as it works on entering several random values and then outputs the largest and smallest value entered.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education