Question

In: Computer Science

Discuss the relative efficiency of the enqueue and dequeue operations for an array-based queue implemented with...

Discuss the relative efficiency of the enqueue and dequeue operations for an array-based queue implemented with a fixed-front approach as opposed to a floating-front approach.

Solutions

Expert Solution

A queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue).

For an array based queue we could implement enqueue by adding the new item at the end of the array and implement dequeue by saving the first item in the array, moving all other items one place to the left, and returning the saved value. The problem with this approach is that, although the enqueue operation is efficient, the dequeue operation is not, it requires time proportional to the number of items in the queue.

Now relative efficiency of the enqueue and dequeue operations for an array-based queue implemented with a fixed-front approach as opposed to a floating-front approach------>

Fixed Front:

It involves more work because the system has to keep track of both the rear and front and move all elements of the Queue up towards the front.

Floating Front:

It involves less work because instead of the System moving the elements forward towards the front, enqueue and dequeue can add or remove elements from either the front or the back and the elements do not move. Only the front and back move. Because of the fact that the elements do not move, floating front is much more efficient.


Related Solutions

In Java: Initiate empty queue of strings and recreate .isempty, .size, .dequeue, .enqueue methods. //You may...
In Java: Initiate empty queue of strings and recreate .isempty, .size, .dequeue, .enqueue methods. //You may not use the original methods of the stack api to answer. You may not add any more fields to the class. import java.util.NoSuchElementException; import edu.princeton.cs.algs4.Stack; public class StringQueue {    //You may NOT add any more fields to this class.    private Stack stack1;    private Stack stack2;    /**    * Initialize an empty queue.    */    public StringQueue() { //TODO   ...
Create a dynamic array-based Queue ADT class in C++ that contains enqueue(Inserts newElement at the back...
Create a dynamic array-based Queue ADT class in C++ that contains enqueue(Inserts newElement at the back ) and dequeue(Removes the frontmost element ). If the size of the array is equal to the capacity a new array of twice the capacity must be made. The interface is shown: class Queue { private: int* elements; unsigned elementCount; // number of elements in the queue unsigned capacity; // number of cells in the array unsigned frontindex; // index the topmost element unsigned...
Suppose you start with an empty queue and perform the following operations: enqueue 1, enqueue 2,...
Suppose you start with an empty queue and perform the following operations: enqueue 1, enqueue 2, dequeue, enqueue 3, enqueue 4, dequeue, enqueue 5. What are the resultant contents of the queue, from front to back? Group of answer choices 1, 2, 3, 4, 5 1, 3, 5 1, 2, 3 3, 4, 5 Assume you are using the text's array-based queue and have just instantiated a queue of capacity 10. You enqueue 5 elements, dequeue 4 elements, and then...
Task 3: Implement a queue through circular linked list. Develop enqueue, dequeue, status, isempty and isfull...
Task 3: Implement a queue through circular linked list. Develop enqueue, dequeue, status, isempty and isfull functions. Test your code in main function with 10 elements Note: for each task, you are supposed to create three files as specified in task1, i.e., implementation file, interface file and file containing point of entry. in C++
The following sequence of operations essentially leaves a queue unchanged. Group of answer choices enqueue followed...
The following sequence of operations essentially leaves a queue unchanged. Group of answer choices enqueue followed by dequeue dequeue followed by enqueue two enqueues followed by two dequeues two isEmptys followed by two isFulls A standard linked list provides a good implementation of a "Deque". Group of answer choices True False The main thread of a Java program cannot generate additional threads. Group of answer choices True False The text's link-based queue is being used and holds an empty queue....
Assume you have a stack and a queue implemented using an array of size 4. show...
Assume you have a stack and a queue implemented using an array of size 4. show the content of the array for the stack (then the queue) for the following operations: (for the queue replace push by add and pop by remove; keep in mind that the queue uses a circular array): push(-3), push(-5), push(-9), push(-10), pop(), pop(), push(-13), pop(), push( -15), push(-17). java code
For an organisation that has recently implemented a few IT systems to support business operations, discuss...
For an organisation that has recently implemented a few IT systems to support business operations, discuss one (1) possible benefit that may be derived. Also discuss one (1) problem that may arise. How might this problem be addressed?
Problem A. The pseudocode as below illustrates the basic push() and pop() operations of an array-based...
Problem A. The pseudocode as below illustrates the basic push() and pop() operations of an array-based stack, where top is initialized as 0 when the stack is empty. Assuming that at a given moment, SIZE is equal to 20, top is equal to 8, this code is used in a concurrent environment (top and stack[] are in shared memory section), process P0 is about to call push() and process P1 is about to call pop() concurrently a. Which variable has...
Classify the operational measures as time-based, quality-based, or efficiency-based. Discuss the significance of each category for...
Classify the operational measures as time-based, quality-based, or efficiency-based. Discuss the significance of each category for lean manufacturing. If there is no effect select "Not applicable". Using Net Benefit to Evaluate Risk Response Alternatives Cooper Movie Studio Corp. makes movies and is interested in lowering its operating costs for the following year, while maintaining the high quality and appeal of its movies. Cooper’s management is concerned about the additional costs the company would have to incur if new industry regulation...
Discussing - Network Security a) Discuss the relative merits of traditional signature-based IDS/IPS technology with newer...
Discussing - Network Security a) Discuss the relative merits of traditional signature-based IDS/IPS technology with newer form, such as application awareness and anomaly detection. b) Discuss and develop a theoretical network architecture for a small business in the area that wishes to expand into new facilities, like a colocation center in the downtown area.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT