Aditya Chatterjee's Blog, page 141
November 28, 2021
Swap two bits in a number
In this problem, we have to swap bits in a given number or an integer. This can be solved in constant time O(1) using XOR operation. So before moving towards this problem first we have to understand what is a bit that needs to be swapped.
Table of contents:
Introduction to bits and Problem statementNaive ApproachTime and Space Complexity Analysis of Naive ApproachXOR Swap ApproachTime and Space Complexity analysis of XOR Swap ApproachIntroduction to bits and Problem statementA bit is the...
Array in JavaScript
In this article, we have explored Array in JavaScript in depth along with multi-dimensional array and different array methods like splice(), push() and more.
Table of Content1. Introduction2. Array Structure2.1. Literal Representation2.2. Array() constructor3. Array Types3.1. One-dimensional3.2. Multidimensional4. Methods4.1. Push()4.2. Unshift()4.3. Splice()4.4. Pop()4.5. Length4.6. forEach()4.7. From()4.8. isArray()4.9. Array.of()4.10. Map()4.11. Filter()5. Final Considera...
OOP in JavaScript
In this article, we will talk about Object Oriented Programming (OOP) in JavaScript and have covered different ideas like Inheritance, Encapsulation, Design Patterns and much more.
Table of contents
Introduction of OOP in javascriptobjects in javascriptclass in javascriptEncapsulation and inheritance in javascriptDesign patterns in javascriptINTRODUCTION OF OOP IN JAVASCRIPTJavascript is a language used to add interactive features to our webpages built using html and css. And OOP in java...
November 27, 2021
Concept of Reverse Proxies
In this article, we have explained the Concept of Reverse Proxies, why it is important and the applications of Reverse Proxies. This is an important topic in System Design.
Table of contents:
Introduction to proxy serversTypes of proxiesForward (open) proxyReverse ProxiesImportance of Reverse proxiesConclusionIntroduction to proxy serversIn english language the word proxy refers to the authority to represent someone else in a certain capacity i.e to be able to act or perform some functi...
Union of Two Arrays
If you want to further your knowledge in data structures and algorithms, or you just started to get ready for Placement preparation. Then you should solve this type of question as basic building blocks.
The Union operation combines the results of two or more queries into a distinct single result set that includes all the rows that belong to all queries in the Union. In this operation, It combines two more queries and removes the duplicates.
So let's clear our purpose.
Objective :
Here,we will lo...
Unsafe Rust
Rust has a lot of safety checks that ensure memory safety and allow us to completely avoid a lot of the common errors that plague other languages with unrestricted memory freedom. But sometimes said freedom is required for us to do what we want or have to do as programmers, and that is where Unsafe Rust comes in.
Table of contents
Why and when to use UnsafeThe Five Superpowers of Unsafe RustSuperpowers explainedWhy and when to use UnsafeUsing Unsafe-marked code to take advantage of one or ...
Check if given point is inside a convex polygon
In this post, we discuss how to check if a given point is inside a convex polygon using the Graham scan algorithm and list application areas for the solution.
Table of contents:
Problem StatementGraham scan algorithmApproach to solve the problemTime and Space Complexity AnalysisApplicationsPrerequisite: Graham scan algorithm
Problem StatementProblem statement: Given coordinates of n points of a convex polygon. Return true if the point (x, y) lies inside the polygon, false otherwise.
Inpu...
Basics of JavaScript (variable, datatype, function, array, loop and more)
In this article, we have explained the Basics of JavaScript (variable, datatype, function, array, loop and more).
Table of Contents1. Introduction2. Working with JavaScript in the HTML file3. Type of Variables3.1. Var3.2. Let3.3. Const4. Data Types4.1. String4.2. Number4.3. Boolean4.4. Null4.5. Undefined4.6. Symbol4.7. Object5. Functions6. Array and Methods7. Loop7.1. For7.2. For...in7.3. While8. Math Methods9. Class10. Conditional Structures10.1. If...else10.2. Switch...
Different ways to terminate and pause program in Rust
Rust has multiple built-in ways to terminate the program, and every method has specific behavior whenever it's called. We're going to see how different functions in Rust (which we use to exit the program) act and how to use them.
ContentsDifferent ways of exitingexit()abort()Exiting by panicing the programUsing return to exitPausing the programWhat Rust returns when using functions to exit?...Note that the article contains direct links to the rust-playground for you to try the code.
November 26, 2021
Consistent Hashing
Consistent Hashing is a distributed hashing scheme that operates independently of the number of servers in a distributed hash table.
Table of contents:
HashingHash TableConsistent HashingPrerequisite: Distributed hash table, Hashing
Prior to discussing Consistent Hashing, let us describe what Hashing is.
HashingHashing is the process of transforming a given key into a code with a hash function. A more specific definition of hashing is the practice of taking a string or input key, a variabl...