Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 364 of 377

Worst-Case Tolerance Analysis

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Jan-2020 386 Views

Definition and importance of Tolerance AnalysisTolerance analysis is the term given to a number of processes used to calculate the overall variation and effect of variation on products stemming (i.e. arisen) from imperfections in manufactured parts.Tolerance analysis is performed by product design engineers as they prepare to components for manufacturing. This is done to ensure according to end users’ demand as well as guarantee so that all manufactured components are fitted together within an assembly.The Definition of Tolerance AnalysisTolerance analysis is defined as the general term for activities related to the subject of potential collected variation in mechanical parts and assemblies. ...

Read More

Setting up C++ Development Environment

Arnab Chakraborty
Arnab Chakraborty
Updated on 30-Dec-2019 262 Views

Text EditorThis will be used to type your program. Examples of few editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi.Name and version of text editor can vary on different operating systems. For example, Notepad will be used on Windows and vim or vi can be used on windows as well as Linux, or UNIX.The files you create with your editor are called source files and for C++ they typically are named with the extension .cpp, .cp, or .c.A text editor should be in place to start your C++ programming.C++ CompilerThis is an actual C++ ...

Read More

Cons of using the whole namespace in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 30-Dec-2019 320 Views

In C++, we use different namespaces. We can also create our own namespaces. For example, generally, we use standard namespace called std. We write the syntax like:using namespace std;In the standard library, it contains common functionality you use in building your applications like containers, algorithms, etc. If names used by these were out in the open, for example, if they defined a queue class globally, you'd never be able to use the same name again without conflicts. So they created a namespace, std to contain this change.The using namespace statement just means that in the scope it is present, make ...

Read More

Find the closest pair from two sorted arrays in c++

Arnab Chakraborty
Arnab Chakraborty
Updated on 30-Dec-2019 577 Views

Suppose we have two sorted arrays and a number x, we have to find the pair whose sum is closest to x. And the pair has an element from each array. We have two arrays A1 [0..m-1] and A2 [0..n-1], and another value x. We have to find the pair A1[i] + A2[j] such that absolute value of (A1[i] + A2[j] – x) is minimum. So if A1 = [1, 4, 5, 7], and A2 = [10, 20, 30, 40], and x = 32, then output will be 1 and 30.We will start from left of A1 and right from ...

Read More

Find smallest subarray that contains all elements in same order in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Dec-2019 419 Views

Suppose we have two arrays of size m and n, The task is to find minimum length subarray in the first array, that contains all the elements if the second array. Element in second array may be present in the large array in non-contiguous but order must be same. So if two arrays are like A = [2, 2, 4, 5, 8, 9], and B = [2, 5, 9], then the output will be 5. As the smallest subarray of A, will be [2, 4, 5, 8, 9]. Here all elements like [2, 5, 9] are in the same order. ...

Read More

Find the Nth term of the series where each term f[i] = f[i – 1] – f[i – 2] in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Dec-2019 170 Views

Suppose we have a series called f. Each term of f, follows this rule f[i] = f[i – 1] – f[i – 2], we have to find the Nth term of this sequence. f[0] = X and f[1] = Y. If X = 2 and Y = 3, and N = 3. The result will be -2.If we see this closely, there will be almost six terms before the sequence starts repeating itself. So we will find the first 6 terms of the series and then the Nth term will be the same as (N mod 6)th term.Example#include< iostream> using ...

Read More

Find the altitude and area of an isosceles triangle in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Dec-2019 396 Views

Consider we have the side of the isosceles triangle, our task is to find the area of it and the altitude. In this type of triangle, two sides are equal. Suppose the sides of the triangle are 2, 2 and 3, then altitude is 1.32 and the area is 1.98. Altitude(h)=$$\sqrt{a^{2}-\frac{b^{2}}{2}}$$ Area(A)=$\frac{1}{2}*b*h$ Example #include #include using namespace std; float getAltitude(float a, float b) {     return sqrt(pow(a, 2) - (pow(b, 2) / 4)); } float getArea(float b, float h) {     return (1 * b * h) / 2; } int main() {     float a = 2, b = 3;     cout

Read More

Find minimum difference between any two element in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Dec-2019 814 Views

Suppose we have an array of n elements called A. We have to find the minimum difference between any two elements in that array. Suppose the A = [30, 5, 20, 9], then the result will be 4. this is the minimum distance of elements 5 and 9.To solve this problem, we have to follow these steps −Sort the array in non-decreasing orderInitialize the difference as infiniteCompare all adjacent pairs in the sorted array and keep track of the minimum oneExample#include #include using namespace std; int getMinimumDifference(int a[], int n) {    sort(a, a+n);    int min_diff = INT_MAX;    for (int i=0; i

Read More

Find three closest elements from given three sorted arrays in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Dec-2019 455 Views

Suppose we have three sorted arrays A, B and C, and three elements i, j and k from A, B and C respectively such that max(|A[i] – B[i]|, |B[j] – C[k]|, |C[k] – A[i]|) is minimized. So if A = [1, 4, 10], B = [2, 15, 20], and C = [10, 12], then output elements are 10, 15, 10, these three from A, B and C.Suppose the size of A, B and C are p, q and r respectively. Now follow these steps to solve this −i := 0, j := 0 and k := 0Now do the following ...

Read More

Find pair with maximum difference in any column of a Matrix in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 18-Dec-2019 160 Views

Suppose we have one matrix or order NxN. We have to find a pair of elements which forms maximum difference from any column of the matrix. So if the matrix is like −123535967So output will be 8. As the pair is (1, 9) from column 0.The idea is simple, we have to simply find the difference between max and min elements of each column. Then return max difference.Example#include #define N 5 using namespace std; int maxVal(int x, int y){    return (x > y) ? x : y; } int minVal(int x, int y){    return (x > y) ? ...

Read More
Showing 3631–3640 of 3,768 articles
« Prev 1 362 363 364 365 366 377 Next »
Advertisements