Aditya Chatterjee's Blog, page 200

June 25, 2020

Transitive Closure Of A Graph using Floyd Warshall Algorithm

Transitive Closure Of A Graph using Floyd Warshall Algorithm

Transitive Closure Of A Graph using Floyd Warshall Algorithm


In this article, we will begin our discussion by briefly explaining about transitive closure and the Floyd Warshall Algorithm. We will also see the application of Floyd Warshall in determining the transitive closure of a given graph.


What is Transitive Closure of a graph ?

In any Directed Graph, let's consider a node i as a starting point and another node j as ending point. For all (i,j) pairs in a graph, transitive closure matrix is formed by the reachability factor, i.e if j is reachable fro...

 •  0 comments  •  flag
Share on Twitter
Published on June 25, 2020 05:10

unordered_set in C++ STL

In this article we are going to discuss about the unordered_set container class of the C++ Standard Template Library. unordered_set is one of the most useful containers offered by the STL. It provides search,insert,delete in O(1) on average. We'll talk more about the worst case complexity later.


Declaring a set
unordered_set any_name_you_want

We can even pass self defined objects in the template above.


A peek under the hood

You may be thinking how this data structure can offer search,insert,d...

 •  0 comments  •  flag
Share on Twitter
Published on June 25, 2020 02:58

June 24, 2020

John McCarthy, Man behind Garbage Collection

John McCarthy, Man behind Garbage Collection

John McCarthy was one of the most influential Computer Scientists in 1950s and a Professor at Stanford University for nearly 38 years. He is best known for:



Developed LISP Programming Language
Inventing Garbage Collection (which is widely used and popularized by Java)
Inventing the word "Artificial Intelligence" (AI) and is one of the founding members of the domain
First person to propose the idea of Utility/ Cloud Computing publically
Contributed greatly to ALGOL Programming Language

John McCarthy, Man behind Garbage Collection


John M...
 •  0 comments  •  flag
Share on Twitter
Published on June 24, 2020 07:42

June 23, 2020

Cin and Cout in C++

Reading time: 30 minutes | Coding time: 10 minutes


C++ uses the concept of streams to perform I/O operations. A stream is a sequence of bytes in which character sequences are 'flown into' or 'flow out of'. Streams operate as the intermediate between the program and the I/O devices thus helping the programmers to achieve device independent I/O operations. The two types of streams in C++ are:



input stream
output stream

IOstreams-1


Headerfiles available in C++ for Input/Output Operations :



iostream - ios...
 •  0 comments  •  flag
Share on Twitter
Published on June 23, 2020 03:16

Advantages and Disadvantages of Logistic Regression

Reading time: 25 minutes


Logistic Regression is one of the supervised Machine Learning algorithms used for classification i.e. to predict discrete valued outcome. It is a statistical approach that is used to predict the outcome of a dependent variable based on observations given in the training set.


Advantages


Logistic Regression is one of the simplest machine learning algorithms and is easy to implement yet provides great training efficiency in some cases. Also due to these reasons, training...

 •  0 comments  •  flag
Share on Twitter
Published on June 23, 2020 02:23

June 22, 2020

Gale Shapley Algorithm for Stable Matching problem

Reading time: 30 minutes | Coding time: 10 minutes


Gale Shapley Algorithm is an efficient algorithm that is used to solve the Stable Matching problem. It takes O(N^2) time complexity where N is the number of people involved.


images


Stable Matching problem
Introduction

We have 2 sets of people:



The first set contains females
The second set contains males.

Each person in each set has a list of preferences which includes all the people from the opposite set. That is, every woman in the set has a pref...

1 like ·   •  0 comments  •  flag
Share on Twitter
Published on June 22, 2020 15:32

Minimum Increment and Decrement operations to make array elements equal

Reading time: 30 minutes | Coding time: 10 minutes


We are given an array, we need to find the minimum number of increment and decrement operations (by 1) required to make all the array elements equal.


Let us understand this problem with the help of an example:


We need to make the elements of this array equal : arr [] = {2,4,5,7,10}.


It is important to note here, that though we can make the array elements equal to any number in the array but we are asked to find out the minimum number of operati...

 •  0 comments  •  flag
Share on Twitter
Published on June 22, 2020 14:46

Minimum number of increment (by 1) operations to make elements of an array unique

Reading time: 35 minutes | Coding time: 10 minutes


We are given a sorted array (if not, then sort it using any sorting algorithm or built in functions) which might have duplicate elements, our task is to find the minimum number of increment (by 1) operations needed to make the elements of an array unique.


Example : Consider a sorted array - x [1,2,4,4,4,5].

i=0 : x[i] = 1 (Unique)

i=1 : x[i] = 2 (Unique)

i=2 : x[i] = 4 (Unique)

i=3 : x[i] = 4 (increment once to get 5) => res = 1

i=4 : x[i] = 4...

 •  0 comments  •  flag
Share on Twitter
Published on June 22, 2020 11:47

Command Pattern in Java

Reading time: 15 minutes


The command pattern is a behavioral-based design pattern that encapsulates a request/action in an object without knowing the internal operations.


The idea is to create an interface of commands as objects that can be called while being able to decouple the object that performs the action and the object that invokes the action. We have explored it in Java.


Problem

Take for instance, the typical programs we wrote when we coded our first programs. Often times we would use a...

 •  0 comments  •  flag
Share on Twitter
Published on June 22, 2020 11:04

June 21, 2020

Build a Static Website using Gatsby

[image error]

[image error]

The world of web developement is constantly changing as different JavaScript Frameworks and Tools provide different approaches to web development. But large number of websites on the internet are simple informative sites like marketing sites and blogs which don't require much complex structure.In such scenarios static websites generators like Gatsby, Hugo and Jekyll comes in the picture.


In this article, we are going to build a static website using Gatsby. Gatsby is React based, GraphQL powere...

 •  0 comments  •  flag
Share on Twitter
Published on June 21, 2020 14:32