Aditya Chatterjee's Blog, page 203

June 11, 2020

Multiple Inheritance in Java (using Interface)

Java is an Object Oriented Programming language and supports the feature of inheritance. We cannot have Multiple Inheritance in Java directly due to Diamond Problem but it can be implemented using Interfaces. We have explained this in detail starting with basic introduction to inheritance.


Inheritance is inheriting the properties of one class(Parent class) in the another class(child class). This relation can be defined by using the extends keyword as −


public class child extends parent{
}

The ...

 •  0 comments  •  flag
Share on Twitter
Published on June 11, 2020 06:59

Divide and Conquer Optimization in Dynamic Programming

Divide and conquer optimization is used to optimize the run-time of a subset of Dynamic Programming problems from $O(N^2)$ to $O(N logN)$.


Quadrangle inequalities

For a two-variable function $f(x, y)$ :




Convex quandrangle inequality : $\forall_{a \leq b \leq c \leq d}(f(a, c) + f(b, d) \leq f(a, d) + f(b, c))$




Concave quadrangle inequality : $\forall_{a \leq b \leq c \leq d}(f(a, c) + f(b, d) \geq f(a, d) + f(b, c))$




Optimization criteria

A dynamic programming problem of the form:

$$

dp(i...

 •  0 comments  •  flag
Share on Twitter
Published on June 11, 2020 05:55

2-SAT problem

Boolean satisfiability is a NP-complete problem but, a special case of it can be solved in polynomial time. This special case is called cas 2-SAT or 2-Satisfiability.


We have explained the basic ideas to understand this problem with depth along with solution.


Boolean Satisfiability
Boolean formulas

Boolean formulas are ones where the variables can take values 0 (false) or 1 (true). Some operators in Boolean formulas:





Name
Operator




not
$ \neg a $


and
$ a \wedge b $


or
$ a \vee b $


i...
 •  0 comments  •  flag
Share on Twitter
Published on June 11, 2020 05:22

Applications of Catalan Numbers

In this article, we have explored different applications of Catalan Numbers such as:



number of valid parenthesis expressions
number of rooted binary trees with n internal nodes
number of ways are there to cut an (n+2)-gon into n triangles
How many “mountain ranges” can you form with n upstrokes and n downstrokes
How many paths are there of length 2n that lead from the upper left corner to the lower right corner
Number of ways to tile a stairstep shape of height n with n rectangles
number of Bi...
 •  0 comments  •  flag
Share on Twitter
Published on June 11, 2020 05:09

June 10, 2020

Convolution Filters

Convolution filters are filters (multi-dimensional data) used in Convolution layer which helps in extracting specific features from input data. There are different types of Filters like Gaussian Blur, Prewitt Filter and many more which we have covered along with basic idea.


Convolution Filter are the tools to derive the best out of images!


Images are fundamentally, matrices.

sample-matrix

where each digit, represents the intensity of light in that position.


Above is a grayscale image, that may be represente...

 •  0 comments  •  flag
Share on Twitter
Published on June 10, 2020 06:22

June 9, 2020

Implementing Binary tree in C++

Reading time: 25 minutes | Coding time: 40 minutes


In this article, we have explored how to implement Binary Tree Data Structure in C++ including all different operations like traversing, inserting and deleting. We have used Object Oriented Programming (OOP) concepts.


What is a Binary tree? (general form)

A Binary tree is a heirarchichal data structure in which every node has 2 children, also known as left child and right child, as each node has 2 children hence the name "Binary".

Root node is...

 •  0 comments  •  flag
Share on Twitter
Published on June 09, 2020 15:54

Override __getattr__ in Python

Magic methods or Dunder methods in Python are the methods having two underscores around the method's name. "Dunder" isn't some fictional city in Scranton, but it means “Double Under (Underscores)”. These are commonly used for operator overloading. Few examples for magic methods are: __init__, __add__, __len__, __repr__ etc.


There are many methods like these but emphasizing particularly on __getattr__, is called when an atrribute is not found in the usual place(i.e. it is not an instance attrib...

 •  0 comments  •  flag
Share on Twitter
Published on June 09, 2020 15:32

Advantages of Support Vector Machines (SVM)

SVM is one of the supervised algorithms mostly used for classification problems. This article will give an idea about its advantages in general.




SVM is very helpful method if we don’t have much idea about the data. It can be used for the data such as image, text, audio etc.It can be used for the data that is not regularly distributed and have unknown distribution.




The SVM provides a very useful technique within it known as kernel and by the application of associated kernel function we ca...

 •  0 comments  •  flag
Share on Twitter
Published on June 09, 2020 05:30

NamedTuples objects in Python

NamedTuples objects in Python

Reading time: 20 minutes | Coding time: 5 minutes


A Tuple is an ordered and immutable collection of objects. Once initialized you may not change them.



Tuples are used to hold together multiple objects. Think of them as similar to lists, but without the extensive functionality that the list class gives you. One major feature of tuples is that they are immutable like strings i.e. you cannot modify tuples.




Read about Tuples in Python


NamedTuples are Tuples that allow you to:



Name each Tuple f...
 •  0 comments  •  flag
Share on Twitter
Published on June 09, 2020 05:11

June 8, 2020

Typing speed testing tool using Vanilla JavaScript

Typing speed testing tool using Vanilla JavaScript

In this article, we will know how to build a simple tool that can test the typing speed of the users. We will develop this using JavaScript along with HTML and CSS.


Typing speed testing tool using Vanilla JavaScript


Tech stack to be used:

HTML, CSS, JavaScript


Setting up the structure using HTML:

Let's create the skeleton structure of the project.




Typing Speed Tester!




First, we need to inlcude our CSS and JS file link, as shown above.


Now, let's make the boxes where we will show the number of words typed, timer, number of mistypes ...

 •  0 comments  •  flag
Share on Twitter
Published on June 08, 2020 15:27