Computer Science: An Overview (12th Edition)
12th Edition
ISBN: 9780133760064
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
Implement 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…
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.
Write a program to find second maximum value in liner queue.
Chapter 8 Solutions
Computer Science: An Overview (12th Edition)
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 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_forwardCould you give me an example of how waiting in queue works?arrow_forwardIf 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_forward
- Using 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_forwardYou 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 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
- Write 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_forwardUsing Queues Operation Enqueue. Dequeue. Write a algorithm of method names Contain Equal that takes the strrings "aaabbb" in queue form as input and returns that the strings contain equal numbers of a's and b's A A A B B B Quput Must be Like: Both A's and B's are Equal In Quantity Which Is 3.arrow_forwardPlease help me with this! The countOff() method displays the name of each officer removed from the queue, in the order in which they are removed, and displays the name of the officer that goes for help. For example, the output for the queue of defenders above with a count of 4 would appear as:Defenders leaving the queue are: Horace Alsbury, PVT, Kentucky, survivorSimon Arreola, —, —, survivorPeter James Bailey III, PVT, Kentucky, fatalityJohn J. Ballentine, PVT, Pennsylvania, fatalityRobert Allen, PVT, Virginia, fatalityMicajah Autry, PVT, North Carolina, fatalityWilliam Charles M. Baker, CPT, Missouri, fatalityJames L. Allen, PVT, Kentucky, survivorJesse B. Badgett, —, Texas, survivorRichard W. Ballentine, PVT, Scotland, fatalityJosé María Arocha, —, —, survivorJuan Abamillo, SGT, Texas, fatalityIsaac G. Baker, PVT, Arkansas, fatalityJuan A. Badillo, SGT, Texas, fatalityJohn Ballard, —, —, fatalityMiles DeForest Andross, PVT, Vermont, fatality The defender going for help is: George…arrow_forward
- Assume that you have the Queue implementation. Write a method in Queue class so that this method adds the multiplication of the number given in the parameter with the last stored number in queue. (If you do not use Queue, you will not get any credits,). Your answer: Font Size BIU 2三三 = X x E E E の !!arrow_forwardWrite a program in Python to show how a queue works using empty, size, front, back, push item onto queue, and push item off queue.arrow_forwardUsing Queues Operation Enqueue,Dequeue, Write a algorithm of method names Contain_Equal that takes the strrings “aaabbb” in queue form as input and returns that the strings contain equal numbers of a’s and b’s A A A B B B Ouput Must be Like: Both A’s and B’s are Equal In Quantity Which Is 3.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