Arnab Chakraborty has Published 4293 Articles

Binary representation of next greater number with same number of 1’s and 0’s in C Program?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 13:15:25

291 Views

Suppose we have one binary number, that is representation of a number n. We have to find binary representation of a number which is smallest but larger than n, and it also has same number of 0s and 1s. So if the number is 1011 (11 in decimal), then the ... Read More

BFS using vectors & queue as per the algorithm of CLRS in C Program?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 13:10:19

351 Views

In CLRS book the BFS algorithm is described using vectors and queue. We have to implement that algorithm using C++ STL. Let us see the algorithm at first.AlgorithmBFS(G, s) −begin    for each vertex u in G.V - {s}, do       u.color := white       u.d ... Read More

Betrothed numbers in C Program?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 13:06:54

581 Views

Here we will see the Betrothed number. This is a pair of numbers, such that the sum of the proper divisors of one number is one more than the other number. We have to find these pairsFor an example, the pair is like (48, 75). So the divisors of 48 ... Read More

Auxiliary Space with Recursive Functions in C Program?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 13:00:00

405 Views

Here we will see how the auxiliary space is required for recursive function call. And how it is differing from the normal function call?Suppose we have one function like below −long fact(int n){    if(n == 0 || n == 1)       return 1;    return n * ... Read More

Area of the biggest possible rhombus that can be inscribed in a rectangle in C Program?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 12:53:32

135 Views

Here we will see one problem, where one rectangle is given. We have to find the area of largest rhombus that can be inscribed in the rectangle. The diagram will be look like below −The length of the rectangle is ‘l’ and breadth is ‘b’ So the area of the ... Read More

Area of squares formed by joining mid points repeatedly in C Program?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 12:44:02

118 Views

Suppose we have one square whose side is ‘a’. We will make more squares by attaching the mid-points of the squares repeatedly. The number of repetition is n times. We have to find the area of nth square.As the side of the outer square is ‘a’, then area isNow using ... Read More

Area of largest triangle that can be inscribed within a rectangle in C Program?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 12:38:37

156 Views

Suppose one rectangle is given. We know the length L and breadth B of it. We have to find the area of largest triangle that can be inscribed within that rectangle −The largest triangle will always be the half of the rectangle. So it will beExample#include #include using ... Read More

Area of Largest rectangle that can be inscribed in an Ellipse?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 12:33:28

284 Views

Here we will see the area of largest rectangle that can be inscribed in an ellipse. The rectangle in ellipse will be like below −The a and b are the half of major and minor axis of the ellipse. The upper right corner of the rectangle is (x, y). So ... Read More

Area of largest Circle inscribe in N-sided Regular polygon in C Program?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 12:29:48

212 Views

Here we will see how to get the area of the circle which is inscribed in N-sided regular polygon. The N (number of sides) are given, and each side of the polygon is ‘a’The approach is simple. One N sided polygon can be divided into N equal triangles, the whole ... Read More

C Program for area of hexagon with given diagonal length?

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2019 12:23:31

337 Views

Here we will see how to get the area of one hexagon using diagonal length. The diagonal length of the hexagon is d.The interior angles of a regular hexagon are 120° each. The sum of all interior angles are 720°. If the diagonal is d, then area is −Example#include ... Read More

Advertisements