Aditya Chatterjee's Blog, page 70
October 4, 2022
Different ways to convert array to set in C++
In C++ programs, we will often have to convert arrays to other data types. One of these examples is converting from an array to a set.
This is used primarily when we want to remove duplicates from an array, but can also be used for a multitude of other reasons, including sorting a list, or generating faster insertion and deletion times using the set data structure.
In this article, we will discuss the three most common ways to convert an array into a set in C++. Lets jump in!
In short, the appro...
October 3, 2022
Sort Vector of Custom Object in C++ STL
In this article, we will sort a vector having custom object as elements of vector in C++ using comparator.
Table of Contents:ExplanationCreate a ClassSort functionComparator functionCodeInput/OutputTime & Space ComplexityExplanationSuppose we are given an object named Student. It stores the name of Student and the Roll number. All the object is stored in a vector randomly. We are required to sort the vector in terms of increasing Roll number.
We create a custom Object...
October 2, 2022
Different ways to convert vector to set in C++
In this article, we have explored different ways to convert vector to set in C++.
IntroductionVectors and Sets are both containers in C++. Containers are objects which are capable of storing multiple objects of the same type. Containers are usually called STL containers since their classes are defined in the Standard Template Library. In C++ there are three kinds of STL containers: sequential, associative and unordered associative STL containers.
Sequential containers store elements which are ...September 30, 2022
Convert vector to string in C++ [6 methods]
In this article, we have explored different ways of converting vector to string in C++.
Table of contents:
Using string constructorUsing String StreamIndex-based for-loop + String StreamUsing std:: accumulateUsing std:: copyUsing Boost1. Using string constructorIf the given vector is of type char , we can use the range constructor to construct a string object by copying the specified range of characters to it. Here is an example:
#includeusing namespace std;int main(){ vector vect{...September 27, 2022
String isomorphism
In this article, we will learn about string isomorphism and algorithms to solve this problem efficiently.
Table of contents:DefinitionImplementationTwo strings S1 and S2 are said to be isomorphic if there exists a one-one mapping for every character in string S1 to a character in string S2 and the order of characters should be preserved.
Two strings S1 and S2 are isomorphic if each unique character in string S1 can be replaced to get string S2 while preserving the order of the characters.
E...
September 26, 2022
Guess the Programming Language?
5 Questions | 15 minutes
Do you know all languages well enough such that if they speak up one day, you will be able to identify them?
You do not simply write the pseudocode. I am the pseudocode.PythonGoLangCJavaProgrammers often show Python code as the pseudocode.I was once the coolest kid of all and have played with everyone except JavaScript. Who am I?JavaPythonCJavaScriptJava once was the most used language by beating C and C++ to the ground but it has lost some moment...Delta Rule in Neural Network
We shall be discussing Delta rule in neural networks that is used to updated weights during training a Neural Network.
Table of Contents:
IntroductionMathematical DefinitionApplicationDerivation of delta ruleIntroductionThe delta rule is a formula for updating the weights of a neural network during training. It is considered a special case of the backpropagation algorithm. The delta rule is in fact a gradient descent learning rule.
Recall that the process of training a neural network inv...
September 25, 2022
Interview questions on OOP concepts
OOPs, or Object-Oriented Programming is a programming model or paradigm which revolves around the concept of "objects" that mimic real-life entities. It is widely used and is a concept adapted by most of the popular programming languages.
Questions about OOP concepts are asked in every organization during interviews, be it product-based or service based. This article covers the most important questions you need to crack any technical round.
Table of ContentMultiple Choice QuestionsDescriptive...September 24, 2022
Kohonen Neural Network
The Kohonen Neural Network (KNN) also known as self organizing maps is a type of unsupervised artificial neural network. This network can be used for clustering analysis and visualization of high-dimension data.
It involves ordered mapping where input data are set on a grid, usually 2 dimensional. It reduces dimensionality of inputs by mapping its input to a simpler version of itself while preserving its underlying structure. The key characteristic of KNN is that its self organizing...
Heap vs Binary Tree
Today we are going to compare two non linear data structures binary trees and heaps since both are non liner there tend to be confusion regarding both of these usually we will try to remove these confusion.
IntroductionBinary treeSee the summary table of differences at the end of this article
A binary tree is a non-Linear data structure in which each node can have either 0, 1 or 2 child nodes each. Each node consists of
Data portionPointer to left childPointer to right childDepending u...