Question

1. In general, how useful is the Queue data structure? Can you think of other data...

1. In general, how useful is the Queue data structure? Can you think of other data structure? 


2. If we didn’t have the Queue data structure, can you think of another way to implement the FIFO (first in first out) concept? 


Can the Queue ADT accept/handle null entries? Why or why not?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. The Queue data structure is used in a number of ways:

  • It is used in Breadth First Search for Graphs to store the neighbouring edges
  • It is used in CPU and Disk scheduling
  • It is used in Interrupt Handling in real-time systems

A data structure similar to Queue is Stack, the only difference being Queue is First In First Out but Stack is First In Last Out.

2. We can implement a Queue using two Stacks. In case of enqueue, we push the data into the first Stack. In case of dequeue, we pop all elements from first Stack and push them into the second Stack. This reverses the Stack, ensuring that we pop the first element entered. We pop from the second Stack, and push the remaining of the elements in the second Stack to the first Stack.

A Queue can not handle null entries, the reason being that if null entries are accepted it will be impossible to tell if the Queue is empty or there is a null entry at the front of the Queue.

Add a comment
Know the answer?
Add Answer to:
1. In general, how useful is the Queue data structure? Can you think of other data...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3. How can you implement a queue data structure using a doubly linked list? Do you think it is necessary to use a doubl...

    3. How can you implement a queue data structure using a doubly linked list? Do you think it is necessary to use a doubly linked list rather than a singly linked list or not?(3 marks) 3. How can you implement a queue data structure using a doubly linked list? Do you think it is necessary to use a doubly linked list rather than a singly linked list or not?(3 marks)

  • (C++) (VISUAL STUDIO) Circular Queue is a linear data structure in which the operations are performed...

    (C++) (VISUAL STUDIO) Circular Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. In a normal Queue, we can insert elements until queue becomes full. But once queue becomes full, we cannot insert the next element even if there is a space in front of queue. Efficiently implement a queue class using a circular...

  • A limited-sized Queue ADT is an abstract data type that has a limit on the length...

    A limited-sized Queue ADT is an abstract data type that has a limit on the length of the queue. It can be created with a static array of size N, where N is the maximum length of the array. In C, this structure can be defined as follows: typedef struct {int * data;//array of the data on the queue//you may add other attributes here but use as few as possible} queue_t; Write an (efficient) pseudocode for the implementation of each...

  • JAVA Have not gotten the public Iterator<Item> iterator() . Can someone explain it please? import java.util.Iterator;...

    JAVA Have not gotten the public Iterator<Item> iterator() . Can someone explain it please? import java.util.Iterator; /* * GroupsQueue class supporting addition and removal of items * with respect to a given number of priorities and with * respect to the FIFO (first-in first-out) order for items * with the same priority. * * An example, where GroupsQueue would be useful is the airline * boarding process: every passenger gets assigned a priority, * usually a number, e.g., group 1,...

  • In class, we discussed the priority queue (PQ) ADT implemented using min-heap. In a min-heap, the...

    In class, we discussed the priority queue (PQ) ADT implemented using min-heap. In a min-heap, the element of the heap with the smallest key is the root of the binary tree. On the other hand, a max-heap has as root the element with the biggest key, and the relationship between the keys of a node and its parent is reversed of that of a min-heap. We also discussed an array-based implementation of heaps. In this assignment, your task is to...

  • Your assignment is to create and test a class for a queue of objects. You may...

    Your assignment is to create and test a class for a queue of objects. You may use any object class of your choice as the data for the queue.   The instances of the class should have at least one field that distinguishes each instance from other instances of the class (key property, also called a key field). You should complete the software to implement and test your queue and submit the software along with a project report. Your queue class...

  • In C++ Task 3: Use the stack and queue to simulate receiving and transforming data We are creating a system that will co...

    In C++ Task 3: Use the stack and queue to simulate receiving and transforming data We are creating a system that will convert strings sent over a serial bus one character at a time. The conversion will be from big to little endian or from little to big endian. To simplify this, each character will be considered a word. Little endian will have the lowest address first. Big endian will have the biggest address first. For example (for this lab),...

  • Write a program in Java to implement the max-priority queue using max-heap data structure. Implement the...

    Write a program in Java to implement the max-priority queue using max-heap data structure. Implement the max-heap data structure using an integer array of 10 cells. (Do not use Java in-built PriorityQueue class.) [In a max-heap, the root node and the intermediate node vales are always greater than their children.] First, take 10 integer values from the user and insert them in the max-priority queue. Then print the elements of the queue. After that, delete two elements from the queue...

  • Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your...

    Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your own Array-Based Stack (ABS) and Array-Based Queue (ABQ). A stack is a linear data structure which follows the Last-In, First-Out (LIFO) property. LIFO means that the data most recently added is the first data to be removed. (Imagine a stack of books, or a stack of papers on a desk—the first one to be removed is the last one placed on top.) A queue...

  • Write a program: Write all the code for a data-structure that can act like a queue...

    Write a program: Write all the code for a data-structure that can act like a queue or a stack. Items can be pushed/popped from the front and pushed/popped from the back. Put 10 numbers into the structure. Then take it out so you can print it backwards. Then, do the same thing, but print it forward. What is the name of this structure? (Use a stl linked list for the internals) C++ Language

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT