Aditya Chatterjee's Blog, page 206
May 31, 2020
Auto Key Cipher
Autokey (Autoclave) Cipher is a Symmetric polyalphabetic (Polyceaser) substitution cipher. This algorithm is about changing plaintext letters based on secret key letters. Each letter of the message is shifted along some alphabet positions. The number of positions is equal to the place in the alphabet of the current key letter.
Note: Cipher text is also called as encrypted text(don't confuse). And we're assuming index starting from 0 not 1.
Example Test Cases
Case-1:
Input:
Enter the Single Key ...
Play Fair Cipher
Play Fair Cipher comes under a Substitution cipher's category and this cipher was the first practical digraph substitution cipher. In play fair cipher unlike traditional cipher, we encrypt a pair/digraph of alphabets (digraphs) instead of a single alphabet.
Sample Test Case:
Key: "harry"
Plain Text: "My Name is Ravi"
Encrypted Text: "SF KBLF MO YRUK"
Decrypted Text: "MY NAME IS RAVI"
Note:*
Assume above test case throughout the discussion/process.
Choose characters either be lowercase or up...
May 30, 2020
Finding the Largest Element in an Array

We are given an integer array of size N or we can say number of elements is equal to N. We have to find the largest/ maximum element in an array. The time complexity to solve this is linear O(N) and space compexity is O(1). Our efficient approach can be seen as the first step of insertion sort. In fact, this can be extended to find the k-th largest element which will take O(K * N) time and using this to sort the entire array will take O(N^2) time.If we have extra information, we can take its ad...
How is 'this' reference in Java used?
The 'this' keyword in Java is a reference (which means it manages some relation) to the current object where it is called (can be constructor,function etc). It helps to keep the control of scope to access variables or any other elements. this keyword is very powerful and widely used in complex Java application.
Usage of 'this'
Here is given the 6 usage of java this keyword.
this can be used to refer current class instance variable.
this can be used to invoke current class method.
this() can be...
Bernoulli Naive Bayes
Bernoulli Naive Bayes is a variant of Naive Bayes. So, let us first talk about Naive Bayes in brief. Naive Bayes is a classification algorithm of Machine Learning based on Bayes theorem which gives the likelihood of occurrence of the event. Naive Bayes classifier is a probabilistic classifier which means that given an input, it predicts the probability of the input being classified for all the classes. It is also called conditional probability.
Two important assumptions made for Naive Bayes Cla...
begin() and end() in Array C++ STL
In this article, we have explored begin() and end() functions in Array container of C++ STL in depth. We have covered the basic idea of iterators as well as both functions deal with iterators.
Array is a container whose size is fixed. Container is an object that holds same datatype.Array size cannot be allocated dynamically.
SYNTAX of array container:
array array_name;
This above code creates an empty array of object_type and its size equals to array_size. However, array can also be created wi...
May 28, 2020
How I mastered Machine Learning as a Fresher?
![]()
“Karma of humans is Artificial Intelligence”
Let's quickly run through the topics this post covers:
Introduction to my background so that you can understand how I started to understand ML on my own.
We'll commence with the question "why" because before diving deep into something, we must understand the essence of it.
Then we'll cover the essentials that one must know, to get an extensive insight into machine learning.
We then proceed to see "what" exactly is machine learning, and get rid of a...
Different ways of Initializing multimap in C++
Multimaps in C++ STL are similar to maps in C++. The only difference is that maps cannot contain duplicate keys, whereas multimaps can contain multiple similar keys. It is a container that holds key-value pairs (like maps), and allows multiple entries with the same key.
Syntax for multimap :
template , //multimap::key_compare
class Alloc = allocator > //multimap::allocator_tpe
> class multimap;
The different ways to initialize multimaps are:
Method 1: Inserting usin...
Postman Sort
Did you know that an array of number can be sorted on the basis of significant digits? Let's see how!.
A highly engineered variant of top-down radix sort where attributes of the key are described so the Sorting algorithm can allocate buckets and distribute efficiently.
Postman sort works by sorting the integers of an array from their most significant digits to their least significant digits. In the Postman sort the integer having most significant digits and the number of elements in that intege...
Counter Objects in Python
Reading time: 15 minutes | Coding Time: 10 minutes
A counter is basically a part of collections module and is a subclass of a dictionary which is used to keep a track off elements and their count. In Python, elements are stored as =Dict= keys and their counts are stored as dict values. These count elements can be positive, zero or negative integers. Simply speaking, if you add the value ‘hello’ thrice in the container, it will remember that you added it thrice. So, Counter counts hashable objec...