Like stacks and queues even a priority queue can be represented using an array. However, if an array is used to store elements of a priority queue, then insertion of elements to the queue would be easy, but deletion of elements would be difficult This is because while inserting elements in the priority queue they are not inserted in an order. As a result, deleting an element with the highest priority would require examining the entire array to search for such an element- Moreover, an element in a queue can be deleted from the front end only.
No comments:
Post a Comment