Aditya Chatterjee's Blog, page 175
March 23, 2021
Munchausen Number
A number that is equal to the sum of its digits each raised to the power equal to its digit is a Munchausen Number or perfect digit-to-digit invariant(PDDI).
For example :
1.In above example each digit raised to itself on addition equals to number itself.
2.Another number which exhibits this property is 1 .
PseudocodeSo a simple algorithm for identification of Munchausen Number is as follows:
For a given input number break it into constituent digits.Find the sum of each of its digits raise...March 10, 2021
Create a custom UITableView in iOS using Swift

Hello everyone in this article we are going to see how to create a cusotm table view in iOS using Swift.
What is tableview?A table view is a simple list view which is used to represent a collection of data in a list form.It is used extensively used in iOS.For example Messages app in iOS list all the conversations which has a custom cell with sender image and sender name. Another example is iOS Phone app which list recent calls in a table view which has a default type cell with a label for phno,...
Find ancestors of a given node in a binary tree (Recursive + Iterative)
Given a binary tree, we are supposed to find the ancestors of a particular node. An ancestor is a node that is present in the upper layer of a given node. Since the problem revolves around binary trees, a particular node can have atmost 2 children so the ancestor of any given node will be its parent node and the ancestor of the parent node will be its parent node (grandparent node for the particular node in question). We will be printing the ancestors of a particular node until we reach the root...
Find nodes which are at a distance k from root in a Binary Tree
We are given the root of a tree, and an integer k. We need to print all the nodes which are a distance k from the root.
For example, if the given tree is:
Here, the root is 1. If k is 2, then the output should be 4, 5 and 6 as they are at a distance of 2 from the root.
This problem can be solved using a general traversal technique like:
Breadth First SearchDepth First SearchLevel Order TraversalIn Depth First Search (DFS) and Breadth First Search (BFS), we can keep track of the level of ea...
Find ancestors of a node in Binary tree (Recursive)
In this problem, we are given a binary tree and a key k. We need to find out all the ancestors of k.
For example, if k = 7 and the given tree is -
Then, the ancestors of 7 will be 4,2 and 1.
You can simply solve this problem using standard traversal techniques like:
Breadth First SearchDepth First SearchLevel order traversalThe idea is to do that traversal recursively and return 1 when you reach the given node K and return 0 for all other cases. What this does is that: All nodes coming bef...
March 8, 2021
Fractional Cascading in Binary search

In this article, fractional cascading in binary search will be covered. We will go through the reason, implementation and time complexity of the binary cascade.
Fractional Cascading is an optimization over Binary Search to perform Binary Search on K sorted lists to improve the time complexity from O(K logN) to O(logN K).
As we know that the binary search is the algorithm which is used to find the position or existance of the target value in a sorted array by repeatedly dividing the search inte...
C++ Likely and Unlikely attributes
C likely and unlikely attributes came into existence with the release of C 20.
In our C code if we know which lines of code would most probably be executed during our code execution then we can use likely and unlikely attributes , which is our way of saying to the compiler which lines of code would be most probably be executed and thus compiler can optimize it's execution ( by code scheduling ) and that would result in faster code execution.
Before the release of C 20 we ...
March 6, 2021
Vector::pop_back() in C++
In this article, we will learn about pop_back() method of Vector class included in std::vector library. Vectors can be considered as dynamic arrays on the basis of its usage. The elements are added and deleted dynamically changing the the size of the vector at runtime which allows users to prefer the vectors over arrays when they want to control the memory or size of the array at runtime. You need to include library for its usage.
vector::pop_back()Deletes the last element from the vector
This...
Introduction to iOS development

Hello everyone. In this article, we are going to see an introduction to iOS development and build a basic iOS app using Swift and UIKit in the process by setting up our environment.
What is iOSiOS previously known as iPhone OS is an operating system created by Apple and released in 2007.It is written in Swift,Objective C,C++ and some assembly code.Every year apple releases new version of iOS in every year.Latest release in 2020 is iOS 14.
How to get into iOS development
For iOS development the...
March 5, 2021
Inspiring Competitive Programmer from India

This 13 year old Kid :
His success is all due to consistency.
In 2020, he achieved the Silver medal at IOI (International Olympiad in Informatics) and represented India.Bronze medal at Asia Pacific Informatics Olympiad (APIO) 2020He happens to become the youngest Red Coder at CodeForces from India. His higgest rating at CodeForces is 2476.3rd in Google Code-In 20185th position at IOITC 2018He started Competitive Programming at the age of 13 and today, he is 18 years old today and he has ...