Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1) Give at least two applications of heaps data structure.

 
 Dijkstra’s algorithm

Dijkstra's algorithm is a step-by-step process we can use to find the shortest path between
two vertices in a weighted graph. This algorithm enables us to find shortest distances and
minimum costs, making it a valuable tool.

Example:

The shortest path, which could be found using Dijkstra's algorithm, is

 Priority queues 

priority queue is an abstract data type similar to a regular queue or stack data structure in which
each element additionally has a "priority" associated with it. In a priority queue, an element with
high priority is served before an element with low priority.for every value in the queue. When a
value is inserted, a priority is assigned to it. The value with the highest priority is always
removed first.

Example: You can think of priority queues like a hospital. Treating patients in a first-in-first-out
(FIFO) approach isn't always a good idea because some patients may be in critical condition. So,
a patient who has a cough may come in and be assigned a low priority. Then a patient may come
in later who has a gunshot wound, and they would be given a high priority and then be treated
first.

2) Discuss the graph algorithm. Give an example.


A graph is an abstract notation used to represent the connection between pairs of objects. A
graph consists of −
 Vertices − Interconnected objects in a graph are called vertices. Vertices are also known
as nodes.
 Edges − Edges are the links that connect the vertices.
There are two types of graphs −
 Directed graph − In a directed graph, edges have direction, i.e., edges go from one
vertex to another.
 Undirected graph − In an undirected graph, edges have no direction.

In the above Graph, the set of vertices V = {0,1,2,3,4} and the set of edges E
= {01, 12, 23, 34, 04, 14, 13}.

Graph Coloring

Graph coloring is a method to assign colors to the vertices of a graph so that no two adjacent
vertices have the same color. Some graph coloring problems are −
 Vertex coloring − A way of coloring the vertices of a graph so that no two adjacent
vertices share the same color.
 Edge Coloring − It is the method of assigning a color to each edge so that no two
adjacent edges have the same color.
 Face coloring − It assigns a color to each face or region of a planar graph so that no two
faces that share a common boundary have the same color.
Chromatic Number

Chromatic number is the minimum number of colors required to color a graph. For example, the
chromatic number of the following graph is 3.

You might also like