Aditya Chatterjee's Blog, page 169
May 20, 2021
Intersection point of two linked lists
Given two linked lists, where the tail of the second list points to a node in the first list, find the node where both the lists intersect.
Consider the following example where the tail of second list points to the fourth node of the first list. The code should return 4 as the intersection point.
A simple (naive) solution is to consider each node of the first list and check if it can be reached from the second list. The first node in the first list that is reachable from the second list is the ...
May 19, 2021
Different ways to insert elements in Deque in C++
We will discuss the insert methods of a badass data structure, i.e. deque, which contains the goodness of both, the good old stack and queue. In it we can access both the front and back thus breaking the LIFO and FIFO barriers. There are also ways to add elements directly in one of the interior positions, though it takes away the saliva inducing constant time complexity, giving us the worse yet not really linear time one. The insert methods discussed here are:
deque::push_back() and deque::push...Flask API using Flask RestFul
Flask is python based web framework which lets developers design complex web applications. It is small and easy to use and is one of the most popular web frameworks with lots of users worldwide and being used in many large scale industries and startups.
We will be developing a flask API using flask restful in which we will be performing all the basic CRUD operations.
The basic CRUD operations include create,read , update and delete. We will be interacting with a mysql database to store our data...
May 17, 2021
Column Sort Algorithm
Column Sort Algorithm is a non-traditional sorting algorithm for Distributed Memory Clusters (DMC) (means multiple processors). It is a generalization of odd-even merge sort and is used in a parralel system where multiple CPUs are available for use.
The time complexity of Column Sort Algorithm is O(N logN / P) where N is the number of elements and P is the number of different processors. There are further restrictions which we have explained further in this article at OPENGENUS.
Column Sort was...
May 16, 2021
Shift OR algorithm for String Matching
The Shift OR algorithm uses bitwise techniques to check whether the given pattern is present in the string or not. It is efficient if the pattern length is lesser than the memory-word size of the machine (In this article at OPENGENUS, we consider the memory-word size to be 64bits). We are given string, string length, and the pattern. Our job is to return the starting index of the pattern if the pattern exists in the string and -1 if it does not exist.
For Example:
Input:
Text: OpengenusPattern...May 15, 2021
Uploading files to FireBase storage from iOS apps

Hello everyone in this article at OPENGENUS, we are going to see how to upload files to FireBase cloud from iOS app. We are going to build a simple app which allow the user to pick an image from their gallery using UIPickerViewController and upload it to firebase cloud storage in png image format.
Lets get startedLogin to your firebase console and create a new iOS app project and addd your iOS app by specifying Bundle ID and other neccessary details
Download the plist file and add it to the...
Using strings and characters in C++ safely
Secure Coding in C++ or why we have to use strings and characters in C++ safely? What is C++, what are Strings and Buffer Overflows? And something about software vulnerabilities and exploits
Let us start from the very beginning and talk a bit about C++, strings and characters. Why is it so important to "code secure" since type-unsafe languages, like C and C++, are prone to such vulnerabilities.
C++ (/ˌsiːˌplʌsˈplʌs/) is a general-purpose programming language created by Bjarne Stroustrup as an e...
System Design of Online Coding Judge (Competitive Programming Platform)
If you are a competitive programmer you don't need an introduction to coding judge.Most of us use coding platforms like Hackerank,Hackerearth,leetCode,CodeChef for practicing coding or to take part in various contests.Ever wondered how it works?Food for mind, think how your code get's executed and judged accordingly after plagiarism check.
What is an online coding judge?
Online coding judge evaluates the algorithmic source code submitted by the platform users and tests it against various test ca...
May 13, 2021
Move the first element of the linked list to the end
In this problem, given a linked list, we move the first element of the linked list to the end of the linked list.
Example input:1 -> 2 -> 2 -> 3Example output:2 -> 2 -> 3 -> 1What are linked lists ?Linked List is a data structure. It is a linear data structure where the elements of the linked list are stored in non-consecutive
memory locations, each node in the linked list contains a data item and pointer to the next node in the linked list.
In our program w...
May 9, 2021
Construct Binary Tree from Inorder and Preorder traversal
In this article at OPENGENUS, we present two approaches to Construct Binary Tree from Inorder and Preorder traversal. We start with background information on constructing Binary Tree from a given traversal or a set of traversals.
IntroductionWhy we cannot use only Inorder traversal to construct Binary Tree?In order to construct a unique binary tree, we cannot rely only on the Inorder Traversal. With only inorder traversal of the binary tree and no more information we may find a binary tree but...