Aditya Chatterjee's Blog, page 194
September 7, 2020
String Pool in Java
In this article, I have explained the String Pool in Java and how to implement it in Java programming. I have covered basic concepts of this topic.Also, I have explain the diagram.
First of all we should know about String. So String is a special class in java and we can create String object using new operator as well as providing values in double quotes.
For example, "opengenus" and "Hello everyone" are both strings
String Pool in a Java is a storage area in Java heap(area of memory used for ru...
September 5, 2020
Multinomial Naive Bayes
Multimodal naive bayes is a specialized version of naive bayes designed to handle text documents using word counts as it's underlying method of calculating probability. Before diving into what multinomial naive bayes is, it's vital to understand the basics.
Basics
Assumption: Each feature has these properties
For instance, a feature could be a word
Are independent
Are equal
Bayes Theorem: P(A|B) = (P(B|A) * P(A)) / P(B)
This is a probabilistic equation that infers a probability from previous ...
Byte Pair Encoding for Natural Language Processing (NLP)
Byte Pair Encoding is originally a compression algorithm that was adapted for NLP usage.
One of the important steps of NLP is determining the vocabulary.
There are different ways to model the vocabularly such as using an N-gram model, a closed vocabularly, bag of words, and etc. However, these methods are either very computationally memory heavy (usually paired with a large vocabularly size), do not handle OOV (out-of-vocabulary) words very well, or run into issues with words that rarely appear....
Travelling Salesman Problem (Bitmasking and Dynamic Programming)
In this article we will start our discussion by understanding the problem statement of The Travelling Salesman Problem perfectly and then go through the basic understanding of bit masking and dynamic programming.
What is the problem statement ?
Travelling Salesman Problem is based on a real life scenario, where a salesman from a company has to start from his own city and visit all the assigned cities exactly once and return to his home till the end of the day. The exact problem statement goes li...
Travelling Salesman Problem (Basics + Brute force approach)
In this article we will start our discussion by understanding the problem statement of The Travelling Salesman Problem perfectly and then go through the naive bruteforce approach for solving the problem using a mathematical concept known as "permutation"
What is the problem statement ?
Travelling Salesman Problem is based on a real life scenario, where a salesman from a company has to start from his own city and visit all the assigned cities exactly once and return to his home till the end of th...
August 31, 2020
script and scriptreplay in linux

script and scriptreplay are pre-installed commands in Linux. They are more like the utilities which allow the user to record their terminal session and to refer to it anytime he/she needs it. It is a command-line utility, so can run any Linux machine.
script Command
Script commad helps us to record everything printed on the terminal to a dedicated log-file. After executing the command everything present on the terminal will be recorded, be it the typing of commands or the output. When a dedicate...
Cycle Detection Algorithms
As we have already seen various algorithms to detect a cycle in a linked list. In this article we are going to explore some more cycle detection algorithms in general.
A cycle in a data structure as we have already seen is a condition with no end.
Here are a few popular cycle detection algorithms:
Floyd's cycle detection algorithm
Brent’s Cycle Detection Algorithm
Both of these algorithms are used to find the cycle in a linked list.Both of the algorithms use the slow and fast pointer approach ...
Finding the length of a loop in linked list
In this article we will look at the method of finding the length of a loop in a linked list.For that you should be able to understand the floyd's loop detection algorithm.
Here is a picture that shows the cycle/loop in a linked list with a length of 4.
Before we move forward with the length of cycle in a linked list, let's look at the floyd's cycle finding algorithm.
floyd's cycle finding algorithm
Here is the working of the algorithm.
A slow and a fast pointer is used.
Slow pointer moves by o...
Detect a loop in a linked list (3 methods)
A linked list a liner data structure. A linked list can be of many type. Some popular linked lists are given below:
Single Linked List
Double Linked List
Circular Linked List
Double Circular Linked List
Header Linked List
A Loop in a linked list is a condition when a Linked list does not have any end. That means the last pointer does not point to null in case of single and double linked list and to the head of the linked list in case of circluar linked list insted it points to some other node ...
August 30, 2020
Alternatives to Vector in C++
In this article, we have explored the alternatives of Vector in C++ such as:
array
Deque
Linked List
map
multiset
What is Vector ?
Vector is a dynamic array which resizes itself when insertion and deletion operations perform.Insertions are preformed at the end and in deletion when element gets deleted every element move next to the position i-1.
Array
An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same data-type together.Foll...