Aditya Chatterjee's Blog, page 180
January 30, 2021
Find if a given Binary Tree is a Sub-Tree of another Binary Tree
A sub-tree is a tree itself that is the subset of a bigger binary tree. A subtree of a node means that it is the child of that node. In this article, we will find out different ways to find out if a given binary tree is a sub-tree of another binary tree.
To understand this concept better, let us consider an example of a tree 'Target'.
Now, let us consider another tree called 'Source'.
Now, we will start to check from the root node of 'Target', that is 'a'. Since, 'a' is not present in 'Source'...
January 29, 2021
Convert Binary Tree to Threaded Binary Tree
In this article, we will focus on different approaches on how to convert a normal binary tree into a threaded binary tree. We will convert our binary tree to single threaded binary tree with right pointers pointing to inorder successor (if it exists).
We can do the inorder traversal of the tree and store it in some queue. Do another inorder traversal and where ever you find a node whose right reference is NULL , take the front element from the queue and make it the rig...
Maximum Sum Decreasing Subsequence (Dynamic Programming)
Given an array of n positive integers, find the sum of the maximum sum decreasing subsequence (msds) of the given array such that the integers in the subsequence are sorted in decreasing order.
A subsequence of array is a sequence of elements from the original array which may or may not be continuous.
In other words, the task is to find a strictly decreasing subsequence with the maximum sum in the given array.
ExampleInput: {10, 12, 5, 7, 9, 1}
Output: 22
Explanation:
The decreasing subsequence...
January 22, 2021
Check if a Binary Tree is Balanced by Height
Binary tree is a special type of data structure that has collection of elements known as nodes. The topmost node is called parent node. Each node has either zero, one or two child nodes. A node with zero children is called Leaf Node or Terminal Node.
In this article, we will explore the algorithm to check if a Binary Tree is balanced by height or not.
Terminologies:
Based on below image let us understand some important terminologies:
If any node has a child node on left and/or right...
Linked List with no NULLs
A Linked list is a dynamic data structure which can grow or shrink on demand. It is usually implemented using NULLs, we will consider an alternative no NULL approach and use placeholder nodes.
IntroductionA linked list is a dynamic data structure made up of a sequence of nodes. These nodes are not stored contiguously in memory but instead each nodes stores a link to the next node. Thus each node has a link that points to the next node in the list.
In the implementation, the last node usually po...
Different Basic Operations in CNN
Convolutional Neural Network is the type of neural network which is used for analysis of visual inputs. Some popular applications of CNN includes image classification, image recognition, Natural language processing etc.
Now, there are certain steps/operations that are involved CNN. These can be categorized as follows:
etc. Let us explore them individually.
i. CONVOLUTI...Comparison b/w Different Advanced Sorting algorithms (Interview preparation)
The day will come when you will apply for the job that you have dreamt of for years, you apply for it and got a call from HR for an interview. Although this article may help you as a recap, you will need a deep understanding of the Sorting algorithms to crack any technical interview. Here we are, to help you chase your dreams!
Not only for the sake of interview preparation, as an enthusiastic programmer it's good to know algorithms.
Let's start learning then!
We have covered:
Shell SortHeap So...StringBuilder in Java (java.lang.StringBuilder)
StringBuilder is a standard library class in Java which can be used in handling string data and is alternative to String Buffer and String data type.
The String class in Java creates an immutable object i.e once a string object is created it cannot be altered.To create a string which can be altered,String Builder Class is used,it creates a mutable sequence of characters.The java.lang.StringBuilder Class contains many methods which can perform various operations such as insert,append,trim,find i...
January 21, 2021
Guide to deploy a Python Web app on Heroku
In this article, we'll be discussing on the steps to deploy a sample / basic Python Web-app on Heroku. Firstly we'll discuss on the Introduction to the article. Secondly, This section is for setting the expectation of the reader as well to make sure they are in the same page of understanding and they are following the article. After that, we'll understand the web-app file structure for the same. Later we'll look into the commands for creating & deploying a app at Heroku.
Following are the secti...
Designing and implementing Binary Tree in JavaScript
Binary Trees are sorts of data structures that have numerous employments. They can be applied in search, 3D computer games, high-bandwidth network switches, some shared projects and cryptography. In this article, we'll investigate the fundamentals and use of double trees and how to implement Binary Tree in JavaScript. We will likewise execute a paired tree model.
Following sections in this article:
What is a Binary TreeTypes of Binary TreessBasic StructuresOperations of a Binary TreeHow do...