Aditya Chatterjee's Blog, page 205

June 4, 2020

K means vs K means++

In this article, we have investigated the distinction between K-means and K-means++ algorithms in detail. Both K-means and K-means++ are clustering methods which comes under unsupervised learning. The main difference between the two algorithms lies in:



the selection of the centroids around which the clustering takes place
k means++ removes the drawback of K means which is it is dependent on initialization of centroid

centroids: A centroid is a point which we assume to be the center of the clu...

 •  0 comments  •  flag
Share on Twitter
Published on June 04, 2020 10:37

Viewing the history of git commits (git log)

Reading time: 30 minutes | Coding time: 10 minutes


Follow a few steps to get along with this tutorial:



Create a directory named git_view_history. Create a python file named hello.py.
Initialize git in this repository. Using command git init.
I have created 3 commits in the repository and it looks as follows:

commit 1:



git commit -m "first commit"

[master (root-commit) 981d5a8] first commit

1 file changed, 1 insertion( )

create mode 100644 hello.py



in this commit, the code simply prints hel...

 •  0 comments  •  flag
Share on Twitter
Published on June 04, 2020 05:49

Undoing Local Changes in Git when in the Working area or Staging area

Reading time: 40 minutes | Coding time: 10 minutes


Before going into our main objective "Undoing Local Changes in Git when in the Working area or Staging area", we will go through two basic concepts "Working area" and "Staging".


What is Working area?


It is the remote local space where you code on your machine. You have not added your code to git yet.


What is staging?


It means to prepare a file for a commit. You have added your file to git staging area, but not committed it yet.


Staging area l...

 •  0 comments  •  flag
Share on Twitter
Published on June 04, 2020 05:20

Explaining Blockchain intuitively to a Five year old!

Reading time: 30 minutes


What if your Interviewer asks you to explain Blockchain to her in simple English words ? What if you are developing something related to blockchain and your 5 year old cousin really comes up to you and asks you what is blockchain ?


curiouskid


If you know blockchain or you don't, these situations will surely make you think for some time, HOW DO I EXPLAIN BLOCKCHAIN TO YOU!! If you want to tackle this situation, this is probably the right article you are reading.


I would also like ...

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

June 3, 2020

.norm() method of Numpy library in Python

.norm() method of Numpy library in Python

.norm() method of Numpy library in Python


In Machine learning, vectors and matrixes are used extensively to represent features, targets and other parameters and hyperparameters. Calculating the length or magnitude of the vector used in a particular model is often required in several matrix operations or direct implementations in regularization methods. The length of a vector is a positive integer, that speaks on the extent of the vector in space.


In this article, you will know about vector norm and the method to apply them in Python b...

 •  0 comments  •  flag
Share on Twitter
Published on June 03, 2020 15:49

June 1, 2020

Maximum houses a Robber can rob

There are several houses in a society where the security system of two adjacent house is connected. Hence, if a robber robs two adjacent house, police is informed automatically and the robber does not want this to happen. The robber has the information of how much money is stored in each house. The robber needs to rob alternative houses to be safe.


The robber wants to know how many houses can be robbed without informing the police.


Given a list of non-negative integers representing the amount o...

 •  0 comments  •  flag
Share on Twitter
Published on June 01, 2020 05:17

May 31, 2020

Unary and Binary Operations in C++

Operators are the basic building blocks and constitute the essential part of any programming language. With the help of operators we are able to perform multiple operations. Here, in this article we are going to focus on arithmetic operations in C .


There are various arithmetic operators used for performing the arithmetic operations.


Arithmetic oprerations can be categorized into two types-



Unary arithmetic operations
Binary arithmetic operations

UNARY ARITHMETIC OPERATIONS

Operator that tak...

 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 10:41

Implementing Binary search in C++

Binary search is a simple yet efficient searching algorithm which is used to search a particular element's position in a given sorted array/vector.

In this algorithm the targeted element is compared with middle element. If both elements are equal then position of middle element is returned and hence targeted element is found.


If both elements are unequal then if targeted element is less or more than middle element we discard the lower or upper half and the search continues by finding new middle...

 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 10:35

Kadane's Algorithm for largest subarray sum

Kadane's Algorithm is commonly known for Finding the largest sum of a subarray in linear time O(N).


A Subarray of an n-element array is an array composed from a contiguous block of the original array's elements. For example, if array = [1,2,3] then the subarrays are [1], [2], [3], [1,2], [2,3] and [1,2,3] . Something like [1,3] would not be a subarray as it's not a contiguous subsection of the original array.


Difference between Subarray, Substring, Subset and Subsequence
1. SUBARRAY

A subar...

 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 10:27

Reducing Time limit of code in Java

Hey Folks! Being in the world of competitive programming, every one of us often face TLE (Time Limit Exceeded) Errors. Reducing TL of one's code is one of the most crucial phase of learning for programmers.


One of the most popular platform for competetive programming is codechef.

By-default : Codechef has the TL (Time Limit) for any problem as 1 sec. Java Language has a multiplier of 2 and phython has multiplier of 5.


Java being a heavy language, does uses extra space and time for loading the f...

 •  0 comments  •  flag
Share on Twitter
Published on May 31, 2020 10:19