Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 178 of 377

A Puzzle using C Program

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 767 Views

Here we will see one C puzzle question. Suppose we have two numbers 48 and 96. We have to add the first number after the second one. So final result will be like 9648. But we cannot use any logical, arithmetic, string related operations, also cannot use any pre-defined functions. So how can we do that? This is easy. We can do by using Token Pasting operator (##) in C. The Token Pasting operator is a preprocessor operator. It sends commands to compiler to add or concatenate two tokens into one string. We use this operator at the macro ...

Read More

3-Way QuickSort (Dutch National Flag)

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 2K+ Views

The 3-Way QuickSort, also known as the Dutch National Flag algorithm, is an optimized version of the standard QuickSort algorithm. While traditional QuickSort partitions the array into two parts (less than and greater than pivot), 3-Way QuickSort creates three partitions: elements less than pivot, equal to pivot, and greater than pivot. Syntax void partition(int arr[], int left, int right, int *i, int *j); void quicksort3Way(int arr[], int left, int right); Algorithm The partition function divides the array into three sections − partition(arr, left, right, i, j): if right - left

Read More

A Space Optimized Solution of LCS in C Program?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 286 Views

Here we will see one space optimized approach for LCS problem. The LCS is the longest common subsequence. If two strings are "BHHUBC" and "HYUYBZC", then the length of the subsequence is 4. One dynamic programming approach is already there, but using the dynamic programming approach, it will take more space. We need table of order m x n, where m is the number of characters in first string, and n is the number of characters in the second string. Here we will see how to implement this algorithm using O(n) amount of auxiliary space. If we observe the ...

Read More

A Peterson Graph Problem in C Program?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 377 Views

The Peterson Graph is a specific undirected graph with 10 vertices and 15 edges. In this problem, we need to find a walk through the Peterson Graph that realizes a given string pattern. Each vertex is labeled with a letter (A-E), and we must find a path where the sequence of vertex labels matches our target string. ...

Read More

A C/C++ Pointer Puzzle?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 463 Views

This C programming puzzle demonstrates how pointer arithmetic works with different types of pointers and multi-dimensional arrays. Understanding pointer sizes and type differences is crucial for mastering pointer arithmetic in C. Syntax sizeof(pointer_variable) (char*)(pointer + 1) - (char*)pointer Example: Pointer Arithmetic Puzzle Let's analyze this step-by-step with a complete C program that demonstrates pointer arithmetic with various pointer types − #include int main() { int a[4][5][6]; int x = 0; int* a1 = &x; ...

Read More

3-digit Osiris number C Program?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 230 Views

An Osiris number is a special 3-digit number that equals the sum of all permutations of its 2-digit sub-samples. For example, 132 is an Osiris number because 12 + 21 + 13 + 31 + 23 + 32 = 132. Syntax bool isOsirisNumber(int n); Algorithm The approach is straightforward. For a 3-digit number, each digit appears exactly twice in the permutations − once in the tens position and once in the ones position. Therefore, we can check if the number equals 22 times the sum of its digits. Begin ...

Read More

Binary array after M range toggle operations?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 282 Views

In C, we can solve the binary array toggle problem by applying range operations on an initially zero-filled array. Given an array of size n (initially all zeros) and M toggle commands, each command toggles all bits in a specified range [a, b]. This problem demonstrates bit manipulation using the XOR operation. Syntax void toggleCommand(int arr[], int start, int end); // Toggles bits from index start to end (inclusive) Algorithm toggleCommand(arr, a, b) Begin for each element e from index a to b, do ...

Read More

Biggest Square that can be inscribed within an Equilateral triangle?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 334 Views

Here we will find the side length and area of the biggest square that can be inscribed within an equilateral triangle. Given an equilateral triangle with side length 'a', we need to determine the maximum square that fits inside it. Triangle a x Side = a Syntax float squareSide = a / (1 + 2/sqrt(3)); float squareArea = squareSide * squareSide; Where 'a' ...

Read More

Biggest Reuleaux Triangle within A Square?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 158 Views

Here we will see the area of biggest Reuleaux triangle inscribed within a square. The side of the square is 'a'. And the height of the Reuleaux triangle is h. h = a a a Side = a The height of the Reuleaux triangle is same as a. So a = h. ...

Read More

Biggest Reuleaux Triangle within a Square which is inscribed within a Circle?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 176 Views

Here we will see the area of biggest Reuleaux triangle inscribed within a square, that square is inscribed inside one circle. The side of the square is a and the radius of the circle is r. As we know that the diagonal of the square is the diameter of the circle. Circle (radius r) Square (side a) Reuleaux Triangle Syntax float areaReuleaux(float radius); Mathematical Relationship Since the diagonal of the square equals the diameter of the ...

Read More
Showing 1771–1780 of 3,768 articles
« Prev 1 176 177 178 179 180 377 Next »
Advertisements