Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 20.6, Problem 20.9CP
Program Plan Intro
Queue:
- The queue is a linear data structure used to store a set of data.
- The queue is a collection of data that are accessed in FIFO (first-in-first-out) order for performing the operations.
- A queue is opened at both its ends. One end is for inserting items to the queue and the other end is for removing the items from the queue.
- The two basic operations performed on queue are,
- enqueue() – add an item to queue.
- dequeue() – remove an item from the queue.
- The queue does not have fixed size.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A data structure called a deque is closely related to a queue. The name deque stands for “double-ended queue.” The difference between the two is that with a deque, you can insert, remove, or view from either end of the queue. Implement a deque using arrays
Explain the differences between a statically allocated array, a dynamically allocated array, and a linked list.
In 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.
Chapter 20 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 20.3 - Prob. 20.1CPCh. 20.3 - Prob. 20.2CPCh. 20.3 - Prob. 20.4CPCh. 20.3 - Prob. 20.5CPCh. 20.6 - Prob. 20.6CPCh. 20.6 - Prob. 20.7CPCh. 20.6 - Prob. 20.8CPCh. 20.6 - Prob. 20.9CPCh. 20 - Prob. 1MCCh. 20 - Prob. 2MC
Ch. 20 - Prob. 3MCCh. 20 - The concept of seniority, which some employers use...Ch. 20 - Prob. 5MCCh. 20 - Prob. 6MCCh. 20 - Prob. 8TFCh. 20 - Prob. 9TFCh. 20 - Prob. 10TFCh. 20 - Prob. 1FTECh. 20 - Prob. 2FTECh. 20 - Prob. 3FTECh. 20 - Prob. 4FTECh. 20 - Prob. 5FTECh. 20 - Prob. 1AWCh. 20 - Prob. 2AWCh. 20 - Suppose that you have two stacks but no queues....Ch. 20 - Prob. 1SACh. 20 - Prob. 2SACh. 20 - Prob. 3SACh. 20 - Prob. 4SACh. 20 - Prob. 5SACh. 20 - Prob. 6SA
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Stack stores elements in an ordered list and allows insertions and deletions at one end. The elements in this stack are stored in an array. If the array is full, the bottom item is dropped from the stack. In practice, this would be equivalent to overwriting that entry in the array. And if top method is called then it should return the element that was entered recently.arrow_forwardA deque data structure and a queue are related ideas. The abbreviation "deque" stands for "double-ended queue." A deque differs from the other two in that you may insert, remove, or view from either end of the queue. Implement a deque using arrays.arrow_forwardIn which scenarios would you prefer to use an array over a linked list, and vice versa?arrow_forward
- Programming language: Java Topic: linked listarrow_forwardThe usage of static arrays or dynamically split memory areas may be utilized to maintain linked lists in memory. What are the advantages and disadvantages of each method?arrow_forwardThe implementation of a queue in an array, as given in this chapter, uses the variable count to determine whether the queue is empty or full. You can also use the variable count to return the number of elements in the queue. On the other hand, class linkedQueueType does not use such a variable to keep track of the number of elements in the queue. Redefine the class linkedQueueType by adding the variable count to keep track of the number of elements in the queue. Modify the definitions of the functions addQueue and deleteQueue as necessary. Add the function queueCount to return the number of elements in the queue. Also, write a program to test various operations of the class you defined.arrow_forward
- How is an array stored in main memory? How is a linked list stored in main memory? What are their comparative advantages and disadvantages? Give examples of data that would be best stored as an array and as a linked list.arrow_forwardDescribe the differences between a linked list, a statically allocated array, and a dynamically allocated array.arrow_forwardWhat are the advantages of a linked list versus an array?arrow_forward
- C/C++ Using linked lists implement an amusement park reservation system. The system allows a person to make a reservation for a specific date. A person can change the reservation date or even cancel his booking anytime. The system puts all reservations in a queue. The park will allow only certain number of persons on any given day in order the reservation was made. For each day the system will print out persons allowed to visit the park. For sake of simplicity, dates are being confined to 15th to 30th. The system should ask the user to enter code for different operations. It reads all data from the datafile amusement.dat. The first integer on datafile indicates limit of persons allowed on any day. i)code 1: make reservation, system expects date followed by name (within 20 characters) and makes reservation. If number of bookings exceeds allowed number, then system prints SORRY, QUOTA OVER and moves over to read next code. ii)code 2: change date of reservation, system expects old date,…arrow_forwardRadix Sorting Algorithm In C++, implement the radix sorting algorithm using a queue class.Steps: Create a queue filled with 10 random integers between 1000 and 9999. Next, create a list of 10 empty queues (0-9 digit bins), then dequeue each number from the main queue and enqueue them into the correct digit bin. Dequeue the numbers from each digit bin in order and enqueue them back into the main queue. Repeat the process for every digit (tens, hundreds, thousands, etc.) Finally, print the sorted list.arrow_forwardIn an array based FIFO queue Q, which of the following is correct about the queue after Q.Dequeue( ) is executed? The size of the array is 9 as shown below: 5 (front) 9 8 7 3(rear) 4 front = 1; rear =8 front = 0; rear =7; front = 2; rear =3; front = 0; rear =8;arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning