Session 04 & 05 Flashcards
1
Q
Priority Queue?
A
An abstract data type which behave similar to the linear queue except that each element has priority.
2
Q
Charactistics of Priority Queue?
A
- Every element have some prority
- Higher priority elemets will be removed first, lowest priority elements will be last.
- If two elements have same priority, they will be removed according to the FIFO
3
Q
Linked list prority queue is not good stratergy?
A
- Time complexity for insertion becomes O(N)
- For peek() also O(N)
- Diffifult time and memory management.
4
Q
Heap ?
A
- Tree like data structure that form complete binary tree.
- If a parent node always ordered with respect to child nodes, like
parent node value >= child node value or
parent node value <= child node value,
it is considered as Heap.
5
Q
Two types of Heap?
A
- Max Heap : value of parent node greater than child node
- Min Heap : value of parent node smaller that child node
6
Q
Priority queue types?
A
- Min Priority Queue : Element with least value have high priority
- Max Priority Queue : Element with highest value have high priority
7
Q
Find positions of nodes in Heap?
A
Parent node : A[(i-1)/2]
Left child : A[(2 . i) + 1]
Right child : A[(2 . i) + 2]
8
Q
Applications of Priority Queue?
A
- Digital mapping services in Google Maps
Dijkstra’s shortest path algorithm uses priority queue to find out the optimal path - Data compression in formats like GZIP, WINZIP
Huffman encoding algorithm using priority queue to map data from different file
9
Q
Types of computational complexity classes?
A
- P class
* Polynomial time
* EX :
i) Find maximum matching
ii) Searching - NP class
* Nondeterministic Polynomial time
* EX :
i) Hamiltonian path problem
ii) Graph coloring
iii) Travelling salesman problem - NP hard
- NP complete