GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Ask a Question


Start Coding Today




Data Structures


Interview Experiences

C Programming

C++ Programming

Java Programming



Count the number of ways in which weights can be put on the balance

We are given a balance and n weights of weight 2^0, 2^1, ..., 2^(N − 1), where N is an integer. In a sequence of N moves we place all weights on the balance. In the first move we choose a weight and put it on the left pan. In each of the following moves we choose one of the remaining weights and we add it either to the left or to the right pan. Write a program that computes the number of ways in which we can perform these N moves in such a way that the right pan is never heavier than the left pan.

asked Nov 1, 2016 by anonymous