Arnab Chakraborty has Published 4293 Articles

Rat in a Maze with multiple steps or jump allowed?

Arnab Chakraborty

Arnab Chakraborty

Updated on 31-Jul-2019 12:13:48

463 Views

The rat in maze problem is one of the well-known problem of the backtracking. Here we will see that problem with little variation. Suppose one NxN maze M is given. The starting point is top left corner M[0, 0], and the destination is right bottom corner M[N – 1, N ... Read More

A Puzzle on C/C++ R-Value Expressions?

Arnab Chakraborty

Arnab Chakraborty

Updated on 31-Jul-2019 12:08:17

174 Views

Here we will see one puzzle. Suppose there is a program which is given as below, we have to tell what will be the output and why?Example#include using namespace std; int main() {    int x = 0xab;    ~x;    cout

A Pancake Sorting Problem?

Arnab Chakraborty

Arnab Chakraborty

Updated on 31-Jul-2019 12:06:03

215 Views

Here we will see another sorting problem named Pancake sort. This problem is simple. We have one array. We have to sort this. But we can use only one operation called rev(arr, i). This will reverse the elements of arr from 0 to ith position.This idea is like the selection ... Read More

A nested loop puzzle?

Arnab Chakraborty

Arnab Chakraborty

Updated on 31-Jul-2019 12:03:12

444 Views

In this section we will see one interesting problem. We will see two code segments. Both are with two nested loops. We have to identify which one will run faster. (We will assume that the compiler is not optimizing the code).Segment 1for(int i = 0; i < 10; i++){   ... Read More

A matrix probability question ?

Arnab Chakraborty

Arnab Chakraborty

Updated on 31-Jul-2019 12:01:37

198 Views

Here we will see one matrix probability problem. We have one rectangular matrix. We can move four directions from the current cell with equal probability. These four directions are left, right, up and down. We have to calculate the probability after N moves from position M[i, j].Here we will do ... Read More

attribute((constructor)) and attribute((destructor)) syntaxes in C in tutorials point ?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

3K+ Views

Here we will see how to write a code where two functions are present, and one function will be executed before the main function, and another function will be executed after main function. These features are used to do some startup task before executing main, and some clean up task ... Read More

1 to n bit numbers with no consecutive 1s in binary representation?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

492 Views

In this problem, we have to find some binary numbers which have no consecutive 1s. In a 3-bit binary string, there are three binary numbers 011, 110, 111, who have consecutive 1s, and five numbers are there which have no consecutive 1s. So after applying this algorithm for 3-bit numbers, ... Read More

2’s compliment for a given string using XOR ?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

929 Views

In this section we will see how we can find the 2’s complement using the XOR operation on a binary string. The 2’s complement is actually the 1’s complement + 1. We will use XOR operation to get the 1’s complement.We will traverse the string from LSb, and look for ... Read More

A Boolean Matrix Question in C++?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

256 Views

Here we will see one interesting Boolean matrix problem. One Boolean matrix is given which contains 0’s and 1’s. Our goal is to find where 1 is marked. If the 1 is marked at position mat[i, j], then we will make all entries to 1 of the row i and ... Read More

A C Programming Language Puzzle?

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Jul-2019 22:30:26

478 Views

Here we will see one C programming language 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 ... Read More

Advertisements