Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A priority queue is a queue where a numeric priority is associated with each element. Access to elements that have been inserted into the queue

A priority queue is a queue where a numeric priority is associated with each element. Access to elements that have been inserted into the queue is limited to inspection and removal of the elements with smallest and largest priority only. A priority queue may have multiple items that are of equal priority.

Give the ADT speci?cation for a bounded priority queue using the speci?cation method described in Topic 5 of the lecture notes. By bounded, it is meant that the priority queue has a maximum capacity speci?ed when it is created, and it can never contain more than that number of items.

Your speci?cation must specify the following operations:

newPriorityQueue: make a new queue

insert: inserts an element with a certain priority

isEmpty: test if the queue is empty

isFull: test if the queue is full

maxItem: obtain the item in the queue with the highest priority

minItem: obtain the item in the queue with the lowest priority

deleteMax: remove from the queue the item with the highest priority

deleteAllMax: remove from the queue all items that are tied for the highest priority

deleteMin: remove from the queue the item with the lowest priority

frequency: obtain the number of times a certain item occurs in the queue (with any priority)

Topic 5:A List ADT

---------------------- Name: List

--------------------- Sets:

L : set of lists containing items from G

G : set of items that can be in the list

B : {true,false}

--------------------- Signatures:

newList : ? L

L.isEmpty: ? B

L.insertFirst(g): G ? L

L.?rstItem: image text in transcribed G

L.deleteFirst: image text in transcribed L

---------------------

Preconditions: For all l ? L, g ? G

newList: none

l.isEmpty: none

l.insertFirst(g): none

l.?rstItem: l is not empty

l.deleteFirst: l is not empty

--------------------- Semantics: For l ? L, g ? G

newList: construct new empty list to hold elements from G.

l.isEmpty: return true if l is empty, false otherwise

l.insertFirst(g): g is added to l at the beginning.

l.?rstItem: returns the ?rst item in l.

l.deleteFirst: removes the ?rst item in l.

Please answer the quesion in the form of topic 5, that is Name/Sets/Signatures/Preconditions/Semantics.

Thank you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions