Visualizing Thread-Safe Singletons in Java

Working in Java, we seldom have to create our handwritten singletons, for the existing frameworks like Spring creates these objects for us and maintains them. In enterprise applications, we get into framework disposal and let them create the singletons.

But it is interesting to know the singleton pattern and visualize the famous pattern in a multi-threaded environment. In this article, I will dive deep into this pattern with a multi-threaded environment view.

Graph BFS With Different DS in Adjacency Matrix and Their Usability

This article analyzes the adjacency matrix used for storing node-link information in an array. For a Graph BFS (Breadth-first-search) traversal, we normally tend to keep an adjacency matrix as a 2D array (adj[][]) or array of linkedLists as LinkedList[]. As a result, if an element X is added before element Y, it appears in BFS traversal accordingly. BFS traversal becomes like: ~X,Y,~. What if, the appearance of elements within a breath of a graph needs to be traversed  according to some priority or any rule!!

Say in a breath if Priority of Y > Priority of X, element Y should occur before X in BFS traversal. Say In a breath if Y is added later the X, Y should occur before X in traversal.