Aditya Chatterjee's Blog, page 190
November 2, 2020
Transpose Graph
In this article, we will explore the idea of Transpose Graph along with the basics of Graph Data Structures. We have presented an algorithm to get the transpose of a graph as well.
Background on Data Structure
A Data Structure is a process through which a particular data is stored and can be arranged in the disk space of the computer. By doing so, we can easily manipulate the data for future use.
Data Structure are mainly classified into two types,
Primitive Data Structure
(Example- Int, Char, ...
List of Top Users in CodeForces
In this article, we will make a list of all the users of Codeforces and store their information in a JSON file. We will use the json and urlib.request library of python for the purpose.
We will use Codeforces API to access the data and store the required data in a list. We will finally sort it according to their maxRating to get a list of all users of Codeforces in descending order.
First, let us learn about JSON and API.
What is API?
API stands for Application Programming Interface. An API is a...
November 1, 2020
Different ways to select random element from list in Python
Following are the different ways of selecting a random element from a list:
random.randrange()
random.random()
random.choice()
random.randint()
1. random.randrange() :
using this method we can return a random element from the given list.This method generates random value in the specified range.so for lists we need to specify the range as " random.randrange(len(listname)) ".And we will pass the value returned by the above method into our list to genereate the random elementfrom the list....
October 29, 2020
Number of ways to reach number using increments of 1 and 2 (consecutive 1s are not allowed)
This is a very simple problem, given a number, we need to find the number of ways to reach it using increments of 1 and 2, given consecutive 1s not allowed.
Go through these two problems first to get the complete idea:
Number of ways to reach a given number using increments of 1 and 2
Number of ways to reach a number using increments of 1 and 2 (consecutive 2s are not allowed)
Consider this example to understand the problem clearly:
4
4 can be arrived as:
2+2
1+2+1
1+1+2 (not allowed)
5
5 c...
October 25, 2020
Learn about Body Tag
Pre-requistes: Tags and Attributes of HTML
Well, everything is not difficult to learn, all you need is good internet connection and a cup of coffee to move on with this tutorial!
As the name suggest, body tag defines the body of the webpage. All the basic content of a webpage including heading, paragraph are defined inside the body tag.
Starting from very scratch, body is considered as closing tag, which means it needs to be closed after the work is done. To denote closing tag, we use "/" wit...
October 20, 2020
priority_queue::push() in C++
Note : if you are not familiar with what is a priority queue or how to initialize it, I suggest you to first have a look at this article:
Initialize Priority Queue in C++
Push Function in priority Queue
Push function in priority queue is used to to insert a element in the queue, the element is inserted in the priority queue based on it's value which defines it's priority in the queue.
Position based on priority
If the element is inserted in priority queue is based on max heap then higher the v...
Different Ways to Initialize Priority queue in C++
C++ STL comes with a ton of pre-written code for data structures and algorithms and most of it is not known to most of us therefore in this article i will be teaching you about one of the very useful data structure available in C++ stl called priority queue and also i will showing different ways to initialize it.
Priority Queue
A priority queue is a special type of queue in which each element is associated with a priority and is served according to its priority, value of element itself is consid...
October 18, 2020
Basic Bits hacks in Python

As a Developer we all want to accomplish a task in the least complexity and time. Bits are proved to be very helpful to achieve it to their operations on integer. There are several time saving methods we are going to discuss that you can adopt to boost the performance on the task.
We have covered the following bit hacks:
Compute sign of an integer
Detect if two integer have opposite signs
Swapping two integer values without third variable
Determine if an integer is a power of 2
Negate a Intege...
Typecasting in C
In this article, I have explained about Typecasting in the C language. The definition, categories of Typecasting, Why it is used and How, along with many examples so that it will be easy to understand.
Typecasting simply refers to changing the data type of one variable to another .
For example, changing an int variable to a double, char to int etc. But before we talk about typecasting, we need to first properly understand the concept of data types and their different properties.
We know that in ...
October 16, 2020
Arrays vs Vectors in C++
The differences between array and vectors in C++ are as follows:
Array can be static or dynamic; Vector is dynamic
Array can be traversed using indexes, vector uses iterators
No reallocation in array
Size of Array is fixed; Size of vector can be changed
Vector can be copied using assignment statement
Vector size is not required when we pass a vector to a function
Vector can be returned from function; Array cannot be returned
Arrays are deallocated explicitly; Vectors are deallocated automatical...