Enhancing the Performance of Graph Algorithms

Enhancing the Performance of Graph Algorithms

We use various types of Data Structures according to the need we have. There are numerous Data Structures available in Computer Science and we are going to see about a brilliant one among them, Heaps! ## So, what is Graph? 1 — A complex graph ...

We use various types of Data Structures according to the need we have. There are numerous Data Structures available in Computer Science and we are going to see about a brilliant one among them, Heaps!

So, what is Graph?

1 — A complex graph

Graphs are widely used nowadays. They are used in economics, aviation, physics, biology (for DNA analysis), mathematics, and other fields.

2 — Simple graph with notations

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.

3 — Types of graphs

What about 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.

  1. A star algorithm
  2. Dijkstra’s shortest path algorithm
  3. Bellman-Ford algorithm
  4. Floyd cycle detection algorithm
  5. Brent’s algorithm
  6. Prim’s algorithm
  7. Kruskal’s algorithm
  8. Kosaraju’s algorithm
  9. Tarjan’s strongly connected components algorithm
  10. Kahn’s algorithm
  11. The algorithm based on a depth-first search
  12. Algorithms using the breadth-first search or depth-first search
  13. Greedy coloring
  14. Ford-Fulkerson algorithm
  15. Edmonds–Karp algorithm
  16. Dinic’s algorithm
  17. Hopcroft-Karp algorithm
  18. Hungarian algorithm
  19. Blossom algorithm

So, what is a heap?

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.

4 — Two types of 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.

5 — Same elements in two different heaps

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).

6 — Min-heap construction

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 amount of space. Pointers take up no space; instead, the parent and children of each node can be found using simple arithmetic on array indices.

7 — Heap in an array

The rules (assume the root is stored in arr[0]). For each index i, element arr[i] has children at arr[2_i_ + 1] and arr[2_i_ + 2], and the parent at arr[floor( ( i — 1 )/2 )].

This implementation is especially useful in the heapsort algorithm, as it allows the space in the input array to be reused for heap storage (i.e., the algorithm is in place). However, it necessitates allocating the array before filling it, making this method unsuitable for implementing priority queues where the number of elements is unknown.

It is completely acceptable to implement a binary heap using a traditional binary tree data structure. When adding an element, there is a problem finding the adjacent element on the last level of the binary heap.

data-structures algorithms algorithm-analysis

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Your Data Architecture: Simple Best Practices for Your Data Strategy

Your Data Architecture: Simple Best Practices for Your Data Strategy. Don't miss this helpful article.

Basics of Data Structure Algorithms

In this article, we will be learning algorithms, their characteristics, types of algorithms, and most important the complexity of algorithms.

How To Blend Data in Google Data Studio For Better Data Analysis

Google Data Studio helps us understand the meaning behind data, enabling us to build beautiful visualizations and dashboards that transform data into stories.

Data Structures And Algorithms - Basic Concepts of Algorithmic Analysis

In this video I am going to provide an Introduction to Algorithm Complexity Analysis (Time and Space Complexity). We will see Examples of Basic Operations, Average, Best, and Worst Cases.

SKP's Algorithms and Data Structures

Continuing on the Quick Revision of Important Questions for My Interviews. These Are Good Puzzles or Questions Related to Data Structures. Let's explore it with us now.