Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#ifndef INDEX _ PRIORITY _ QUEUE _ HPP _ #define INDEX _ PRIORITY _ QUEUE _ HPP _ #include #include template class IndexPriorityQueue { private:

#ifndef INDEX_PRIORITY_QUEUE_HPP_
#define INDEX_PRIORITY_QUEUE_HPP_
#include
#include
template
class IndexPriorityQueue {
private:
std::vector priorities {};
std::vector priorityQueue {};
std::vector indexToPosition {};
int size_=0;
public:
explicit IndexPriorityQueue(int);
void push(const T&, int);
void pop();
void erase(int);
bool contains(int) const;
void changeKey(const T&, int);
std::pair top() const;
bool empty() const;
int size() const;
private:
// TODO: you may want to add your own member functions. swim? sink?
};
// Useful helper functions
int leftChild(int i){
return 2*i;
}
int rightChild(int i){
return 2*i +1;
}
int parent(int i){
return i/2;
}
// IndexPriorityQueue member functions
template
IndexPriorityQueue::IndexPriorityQueue(int N){
}
template
bool IndexPriorityQueue::empty() const {
return true;
}
template
int IndexPriorityQueue::size() const {
return 0;
}
template
void IndexPriorityQueue::push(const T& priority, int index){
}
template
void IndexPriorityQueue::pop(){
}
template
void IndexPriorityQueue::erase(int index){
}
template
std::pair IndexPriorityQueue::top() const {
return {T {},0};
}
// if vertex i is not present, insert it with key
// otherwise change the associated key value of i to key
template
void IndexPriorityQueue::changeKey(const T& key, int index){
}
template
bool IndexPriorityQueue::contains(int index) const {
}
#endif // INDEX_PRIORITY_QUEUE_HPP_

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

Step: 3

blur-text-image

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

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions

Question

2. List the advantages of listening well

Answered: 1 week ago