Question: #ifndef INDEX _ PRIORITY _ QUEUE _ HPP _ #define INDEX _ PRIORITY _ QUEUE _ HPP _ #include #include template class IndexPriorityQueue { private:
#ifndef INDEXPRIORITYQUEUEHPP
#define INDEXPRIORITYQUEUEHPP
#include
#include
template
class IndexPriorityQueue
private:
std::vector priorities ;
std::vector priorityQueue ;
std::vector indexToPosition ;
int size;
public:
explicit IndexPriorityQueueint;
void pushconst T& int;
void pop;
void eraseint;
bool containsint const;
void changeKeyconst 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 leftChildint i
return i;
int rightChildint i
return i ;
int parentint i
return i;
IndexPriorityQueue member functions
template
IndexPriorityQueue::IndexPriorityQueueint N
template
bool IndexPriorityQueue::empty const
return true;
template
int IndexPriorityQueue::size const
return ;
template
void IndexPriorityQueue::pushconst T& priority, int index
template
void IndexPriorityQueue::pop
template
void IndexPriorityQueue::eraseint index
template
std::pair IndexPriorityQueue::top const
return T ;
if vertex i is not present, insert it with key
otherwise change the associated key value of i to key
template
void IndexPriorityQueue::changeKeyconst T& key, int index
template
bool IndexPriorityQueue::containsint index const
#endif INDEXPRIORITYQUEUEHPP
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
