Posts

Community Detection Algorithm (Leiden Algorithm in Python)

Community Detection Algorithm (Leiden Algorithm in Python) The Leiden algorithm is a powerful community detection algorithm that is based on the concept of modularity. It is an improvement over the Louvain algorithm, which is a popular algorithm for community detection. The Leiden algorithm is able to identify communities of different sizes and densities and is able to identify overlapping communities. The first step in the Leiden algorithm is to initialize the communities. This can be done randomly or by using some other method. The next step is to calculate the modularity of the network. The modularity is a measure of the density of links within a community compared to links between communities. The higher the modularity, the better the clustering of the network. Once the modularity is calculated, the Leiden algorithm then proceeds to optimize the clustering. It does this by moving nodes between communities in a way that increases the modularity. The algorithm repeats this process un...

PostgreSQL

PostgreSQL Some important points from the PostgreSQL documentation include: Chapter-1 The introduction to the architecture of PostgreSQL in the book "The Internals of PostgreSQL" provides a high-level overview of how the PostgreSQL database management system is structured and how it works. A PostgreSQL server runs on a single host and manages a single database cluster, a collection of databases. Each database objects in PostgreSQL are internally managed by respective object identifiers (OIDs), which are unsigned 4-byte integers. Data is stored in tables as a collection of pages, where each page is a fixed-size block of memory typically 8KB and contains a header and a collection of tuples. Each tuple represents a row in the table and contains the data for each column in the row. The introduction explains the concept of multi-version concurrency control (MVCC) which allows multiple transactions to read and write to the same table simultaneously without conflicts. It also explai...

GDB (GNU Debugger)

  GDB (GNU Debugger) GDB (GNU Debugger) is a powerful tool that allows programmers to analyze and debug their code during development. In this article, we will go over some of the most commonly used GDB commands and how to use them to effectively debug your program. Compiling with -g: To use GDB, you will first need to compile your program with the -g flag. This flag tells the compiler to include additional information in the executable that GDB can use to provide more detailed information about the program. Starting GDB: Once your program is compiled with -g, you can start GDB by running the command "gdb a.out" (assuming the name of your executable is a.out). Setting Breakpoints: The most basic use of GDB is setting breakpoints. Breakpoints allow you to pause the execution of the program at a specific line or function. To set a breakpoint, you can use the command "b" followed by the line number or function name. For example, "b main" will set a breakpoint...

Tree Data Structure

 Tree Definition: A tree is a widely used data structure in computer science. It is a hierarchical structure that consists of nodes, where each node can have one or more child nodes. In C++, a tree can be implemented using classes, objects, and pointers. Binary Tree: One of the most common types of trees is the binary tree, where each node has at most two child nodes. In C++, a binary tree can be represented by a class that has a left and right pointer to represent its child nodes, and a data variable to store the node's value. Here is an example of a binary tree class in C++: class BinaryTree {     public:         int data;         BinaryTree* left;         BinaryTree* right; }; Explanation: This class contains three variables: data, left, and right. The data variable stores the value of the node, and the left and right pointers point to the left and right child nodes respectively. A new node can be created by c...

Recursion

  Recursion Definition : Recursion is a powerful technique in computer programming where a function calls itself in order to solve a problem. It is a way to break down a complex problem into smaller, manageable parts. One of the most common examples of recursion is the calculation of factorials, which is the product of all numbers from 1 to a given number. In C++, a recursive function for calculating factorials would look like this: Example : int factorial(int n) {     if (n == 0) {         return 1;     } else {         return n * factorial(n - 1);     } } Explanation : In this example, the function checks if the input number is 0. If it is, the function returns 1, as 0! = 1 by definition. If the input number is not 0, the function calls itself with an input of n-1. This process continues until the input number is 0, at which point the function returns the product of all the numbers that have been multiplied tog...

Stack and Queues

Image
What is Stack? The basis of stack is first in last out(FILO) Or last in first out (LIFO). To understand stack, consider example of plats. We place plats one over another. Let say we have 5 plats, named as p1, p2, p3, p4, and p5. Assume they are arranged in such a way that p2 is placed on p1, p3 is placed on p2, p4 on p3, and p5 on p4. As shown in the diagram.   Now you are clear with, what is stack. Now we will see where it is used and how we implement stack in c plus plus programming language. Why Stack? We see the functionality of forward and backward operations in our browsers. Similarly, we see functionalities like undo, redo in our text editor or any application like photo editors. The functionality of undo, redo is very common. It is used in many applications like in word, excel, photoshop, browsers, paint, and many other applications. Now if we think about what will be the best way to implement undo, redo functionality in our application, we will see the best data structure ...

Bitcoin

What is Bit coin?  Bit coin is a digital currency. It was invented by Satoshi Nakamoto. It is still unknown whether Satoshi Nakamoto is the name or company or any person. In this article, I will tell you what is bitcoin, how it works, how new bitcoins are generated, how you can earn from bitcoin, from where you can get bitcoin, how to avoid fraud in bitcoin, the best websites for bitcoin selling, purchasing and trading, bitcoin trading, read this blog completely and you will be able to understand the working of bitcoin and all the logic and theories behind bitcoin. Lets get started: Bitcoin: Bitcoin is a digital currency, it was introduced to revolutionize the world. The main idea behind bitcoin is to make the world free from currency notes and to digitalize the world. Another motive behind bitcoin invention was to make a decentralized system of currency. Now let me tell, what is Decentralized system of currency. In Decentralized system of currency there is no one who can manage th...

Singly, Doubly and Circular Linked List

Image
So far, we have seen the implementation of Linked List. The Link List we implemented in the Lined List article was actually Singly Lined List. There is slightly difference between Singly, Doubly and Circular Linked List. We will see the difference and the importance of each in detail in this article.  Singly Linked List: In singly linked list, we keep head node in our linked list class. This head node is actually the starting point of our linked list. As shown: The above Figure shows the representation of Singly Linked List. We have a head node in our linked list class, it is the starting point of our linked list. Every node has some data and next pointer of type Node, that point to the next node of the list. Now I will tell you what is doubly linked list an why we need it. Doubly Linked List: In node of singly linked list, we have only one pointer of type node but in doubly linked list we have two pointers of type node. They are generally named as next and previous. The next point...

Linked List

Linked List: So far, we have studied arrays and pointers. We see, whenever we make an arrays we have to declare its size. i.e my_array[10] or some thing like my_array[10][10] (2D array) . We solve this problem by using pointers. We used to ask size of array from user and then, make dynamic memory of that size. We did something like int* my_array = new int[size] . Where size is given by user. Now let discuss what is its demerit of using this process of creating dynamic memory. Let say, user want to make array of size 20. Using dynamic memory we will create array of size 20 easily, but now let say, user wants to add one more item to this array. i.e he/ she wants to grow this array. What we can do using this strategy, we will make an array of size 21 or more then, transfer the data of previous array the delete the previous array. What's wrong with using this type of implementation? Lets consider, we have made an array of size 10,000,000. Now we want to grow this array to 10,000,001....