Question
In a backtracking algorithm, what happens when a partial
solution is found to violate a constraint?Solution
The core idea of backtracking is to explore a path, and if that path leads to a dead end (violates a constraint or cannot lead to a solution), the algorithm "backtracks" by undoing the last decision and trying an alternative. This pruning of the search space is what makes backtracking efficient compared to brute-force enumeration.
- 25 defective watches got mixed with 175 non-defective watches. A buyer purchases one watch. What is the probability that the watch is defective?
If the letters of the word PARAM are arranged at random, what is the probability that all vowels will come together?
A bag contains 4 red balls, 7 white balls and 6 blue balls. Two balls are drawn simultaneously. Find the probability that both the balls are of same co...
19 rotten bananas are accidentally mixed with 136 good ones. It is not possible to just look at a banana and tell whether or not it is rotten. One banan...
Two fair six-faced dice are thrown simultaneously. Find the probability that the sum of the numbers is 10,
A committee of 4 members is to be formed from 5 men and 3 women. What is the probability that the committee will have exactly 2 women?
Two dice are rolled. What is probability that sum is at least 10?
A bag contains 8 white and some black balls. If the probability of drawing a black ball from the bag is twice that of drawing a white ball, find the num...
Tickets numbered 1 to 50 are mixed up and then a ticket drawn at random. What is the probability that the ticket drawn bears a number which is multipl...
A box contains 8 yellow marbles, ‘x’ blue marbles and 12 white marbles. A box contains 5 yellow marbles, 2 blue marbles and 3 white marbles. The pro...