Depth first search is an algorithm which searches or traverses all the vertices in a graph. It starts to traverse the graph based on a start vertex. The algorithm traverses the vertices in depth. As graphs can have cycles we should not visit any visited vertex twice. For this purpose the algorithm must know if … Continue reading Depth First Search (DFS) in a Graph
Category: Data structures
Breadth First Search (BFS) in a Graph
Breadth first search is an algorithm which searches or traverses all the vertices in a graph. It starts to traverse the graph based on a start vertex. The algorithm traverses the vertices from closest ones to farthest ones. As graphs can have cycles we should not visit any visited vertex twice. For this purpose the … Continue reading Breadth First Search (BFS) in a Graph
Dijkstra’s Algorithm
Dijkstra's algorithm is a popular algorithm created by Edsger W. Dijkstra in 1956 to find the shortest path between two vertices in a weighted graph, where edges have weight or distance which shows the distance/weight between two vertices. The algorithm has many applications in real world like in maps finding the shortest route between two locations, … Continue reading Dijkstra’s Algorithm
Heap and Priority Queue
Binary heap is a tree data structure which satisfies the properties of complete binary tree. This means that every level of the tree except the last one should be filled and the nodes are as far left as possible. The two types of heaps are min and max heap. Min heap is when the the … Continue reading Heap and Priority Queue