Using the Heap matrix as its representation, re-implement the class Priority Queue with the followingmethods. For each method, state its time complexity using the big-Oh notation in terms of m and n.class PriorityQueue<T>{private T[,] H; // Heap matrixprivate int numRows; // Number of rowsprivate int numCols; // Number of columns// 1 mark// Initialize an m x n Heap matrixpublic PriorityQueue ( int m, int n ) { … }// 6 marks// Insert an entry into the priority queuepublic void Insert (T item ) { … }// 6 marks// Remove the item with the highest priority (6 marks)public void Remove ( ) { … }// 1 mark// Return the item with the highest priority (1 mark)public T Front ( ) { … }// 4 marks// Return true if the item is found in the priority queue; false otherwise (4 marks)public bool Found (T item) { … }// 2 marks// Return the number of items in the priority queue (2 marks)public int Size ( ) { … }// 2 marks// Output the Heap matrix (2 marks)public void Print ( ) { … }}
Using the Heap matrix as its representation, re-implement the class Priority Queue with the following
methods. For each method, state its time complexity using the big-Oh notation in terms of m and n.
class PriorityQueue<T>
{
private T[,] H; // Heap matrix
private int numRows; // Number of rows
private int numCols; // Number of columns
// 1 mark
// Initialize an m x n Heap matrix
public PriorityQueue ( int m, int n ) { … }
// 6 marks
// Insert an entry into the priority queue
public void Insert (T item ) { … }
// 6 marks
// Remove the item with the highest priority (6 marks)
public void Remove ( ) { … }
// 1 mark
// Return the item with the highest priority (1 mark)
public T Front ( ) { … }
// 4 marks
// Return true if the item is found in the priority queue; false otherwise (4 marks)
public bool Found (T item) { … }
// 2 marks
// Return the number of items in the priority queue (2 marks)
public int Size ( ) { … }
// 2 marks
// Output the Heap matrix (2 marks)
public void Print ( ) { … }
}
Step by step
Solved in 2 steps with 1 images