Aditya Chatterjee's Blog, page 163

July 29, 2021

Idea of Layer 4 and Layer 7 Load Balancing

In this article, we have covered the idea of Layer 4 and Layer 7 Load Balancing along with advantages and disadvantages. This is an important topic in System Design and is an effective Load Balancing technique.

Table of content:

What is a load Balancer?Layer 4 Load Balancing
3. Advantages of using a Layer4 Load Balancer
4. Disadvantages of using Layer4 Load BalancerLayer 7 Load Balancing
6. Advantages of Layer 7 Load Balancing
7. Disadvantages of Layer 7 Load BalancingLayer 4 vs Layer 7 Load...
 •  0 comments  •  flag
Share on Twitter
Published on July 29, 2021 00:39

July 24, 2021

Factorial of large numbers

The factorial of a non-negative number n, denoted by n!, is the product of all positive numbers less than or equal to n. With the usual approach, we can compute factorial only till 20! due to size limitation of data type. We have present how to overcome this limitation.

Table of content:

Definition of factorialWhat if the number is large, for example 200! ?Approach to find factorial of large numbersTime and Space ComplexityDefinition of factorial

N! = N * (N-1) * (N-2) * ... * 3 * 2 * 1

Ex...

 •  0 comments  •  flag
Share on Twitter
Published on July 24, 2021 13:11

July 23, 2021

Generate all sub-strings of a string

In this article, we have explored the approach of generating / printing all sub-strings of a given String and have provided the implementation to do so. The time complexity to generate all substring is O(N^3) time and there are O(N^2) sub-strings for a string of length N.

Table of content:

What is a Sub-string?Generation of substringsAlgorithm / stepsImplementation in CTime and Space ComplexityUses

Pre-requisites: Arrays, Strings in C

What is a Sub-string?

A substring is a contiguous set ...

 •  0 comments  •  flag
Share on Twitter
Published on July 23, 2021 10:09

July 21, 2021

Shortest Subarray with at least K as sum

In this problem, we find the length of the Shortest Subarray with at least K as sum. This can be solved in O(N) time complexity. This brings in the ideas of Monotonic Queue and Sliding Window.

Table of contents:

Problem StatementHow to approach?Brute Force approachHow to Optimize?Problem Statement

Return the length of the shortest, non-empty, contiguous subarray of nums with sum at least k.

If there is no non-empty subarray with sum at least k, return -1.

Example 1:

Input: nums = [1], k = ...
 •  0 comments  •  flag
Share on Twitter
Published on July 21, 2021 14:17

Time and Space complexity of Radix Sort

In this article, we have explained the Time and Space complexity of the Radix Sort with Mathematical and Intuitive Analysis.

Table of contentsIntroduction of Radix Sort.Time Complexity analysis.Worst case time complexityBest case time complexityAverage case time complexitySpace Complexity analysis.Conclusion on time and space complexityComparison with other sorting algorithms

In short:

Worst case time complexity: O(logb(mx)(n b)); Only one element which has significantly large number ...
 •  0 comments  •  flag
Share on Twitter
Published on July 21, 2021 14:02

July 20, 2021

Counting Sort vs Radix Sort vs Bucket Sort

This article compares counting sort, radix sort, and bucket sort with important points that will help you make out the differences between these sorting algorithms.

Table of content:

Basics of 3 different sorting algorithmsDifferences between Counting Sort, Radix Sort and Bucket Sort
2.1. Time Complexity
2.2. How they work?
2.3. Implementation
2.4. Other important pointsBasics of 3 different sorting algorithmsCounting Sort

Counting sort is a non comparison based linear time sorting algorith...

 •  0 comments  •  flag
Share on Twitter
Published on July 20, 2021 07:19

Most Dangerous Line of Code 💀

Most Dangerous Line of Code 💀

The Most Dangerous Line of Code is "sudo rm -rf * --no-preserve-root /". Do not run it. It has the power to wipe out a Linux system completely and make it useless.

sudo rm -rf * --no-preserve-root /

Most Dangerous Line of Code 💀

Table of content:

What will it do?What to do if I ran this command?How to try this Dangerous command?Lessons learntWhat will it do?

It will delete all files on your system and will also, delete the firmware that is the software that run the motherboard.

Firware provides low level control for ...

 •  0 comments  •  flag
Share on Twitter
Published on July 20, 2021 02:19

July 19, 2021

Idea of Consistency patterns in System Design

In this article, we have explained Consistency Pattern in System Design along with examples for different types like Eventual, Strong and Weak Consistency.

Table of content:

Need for ConsistencyEventual ConsistencyStrong ConsistencyWeak ConsistencyNeed for Consistency

Companies like Google, Facebook or any company in today's world have multiple servers since it is neither efficient nor palatable to have one server.
Moreover, there are different servers based on the geo-location of the user...

 •  0 comments  •  flag
Share on Twitter
Published on July 19, 2021 09:36

July 18, 2021

Cloud Design Patterns

A Cloud Design Pattern as defined by cloud computing experts are a general reusable solution to commonly occuring problems in cloud architecting.They are a collection of solutions and design ideas for using cloud technology to solve common system design problems. The cloud design patterns are used to solve common problems and they are a set of reusable solutions to issues that cloud builders may have during their work.

Table of content:

Why we need Cloud Design Patterns?Some Common Cloud Desig...
 •  0 comments  •  flag
Share on Twitter
Published on July 18, 2021 03:58

Remove K digits to make smallest number

Remove K digits to make smallest number

In this article, we will be solving the problem of removing K digits from a given number to form the smallest number possible without changing the order of the original number. We will use the idea of Monotonic Stack.

Table of content:

Understanding the problemAlgorithm & PseudocodeImplementationsExplanation / Code walk-throughTime and Space ComplexityUnderstanding the problem

In this problem, the user provides us with two input numbers NUM and K, and we have to form the smallest number p...

 •  0 comments  •  flag
Share on Twitter
Published on July 18, 2021 03:52