It is a special type of queue in which each element is associated with a priority and is served according to its priority. Its is based on binary heap (will be dealt with later).
priority_queue<Type, cont, cmp>
comp: When you need to sort based on certain properties, we use comparative functions with two arguements a and b. It returns true if a is supposed to be before b in a vector. example: (Comparator to sort with respect to absolute value)
bool cmp(int a, int b)
{
return abs(a) >= abs(b);
}
sort(v.begin(), v.end(), cmp);
push()
: push element into the queue.pop()
: delete the greatedt element in the queue.top()
: obtain the greatest element of queue.Hashing means associating a value with a key/index.
Hash tables are a type of data structure in which the key/index value of the data element is generated from a hash function. This enables very fast data access as the index value behaves as a key for the data value. This website shows a visualisation of hashing with seperate chaining.
In C++ hashing is used by unordered_map/unordered_set. Normal Map and set will be discussed later.
Next Lesson