Skip to main content

Posts

Showing posts with the label graph algorithms

Enhancing the Performance of Graph Algorithms — Part 2

Introduction to the Heaps, Their Implementations, and Time Complexity Analysis We have seen about the Graph Algorithms and have already discussed their Time Complexity in our previous article “ Enhancing the Performance of Graph Algorithms — Part 1 ”. Heaps A heap is a type of tree-based data structure that fulfills the heap property. Heap Property: If Q is a child node of P, then key(P) ≥ key (Q). As a result, an element with the greatest key is always in the root node, and such a heap is sometimes referred to as a max-heap . There is, of course, a min-heap . For a min-heap, the parent node will always lesser than the child nodes. The root node will have the lowest element. Let’s see how a min-heap is working As in the definition, the min-heap has to follow the heap property. That is if Q is a child node of P, then key(P) ≤ key (Q). The heap can also be stored in an array, which is a more common approach. Because heap is always a complete binary tree, it can be stored in a small...

Enhancing the Performance of Graph Algorithms — Part 1

Introduction to the Graph Algorithms We use various types of Data Structures according to the need we have. We are going to discuss Graphs and the way of optimizing the graphs as required for our problem definitions. What is a Graph? Graphs are widely used nowadays. They are used in economics, aviation, physics, biology (for DNA analysis), mathematics, and other fields. A graph is a non-linear Data Structure with nodes(vertices) and edges in Computer Science that is used to implement the undirected graph as well as directed graph theories from the domain of graph theory within Mathematics. There are two types of Graphs that are needed to this level. Directed graph undirected graph Graph Algorithms One of the crucial operations that can be performed on graphs is traversing or searching. There are several algorithms that work on the Graphs. Such as 1 — Dijkstra’s shortest path algorithm 2 — Greedy algorithm 3 —Astar algorithm 4 — Depth-First Search algorithm 5 — Breadth-First Search ...