A person starts walking from position X = 0, find the probability to reach exactly on X = N if she can only take either 2 steps or 3 steps. Probability for step length 2 is given i.e. P, probability for step length 3 is 1 – P.
Input : N = 5, P = 0.20 Output : 0.32 Explanation :- There are two ways to reach 5. 2+3 with probability = 0.2 * 0.8 = 0.16 3+2 with probability = 0.8 * 0.2 = 0.16 So, total probability = 0.32.
Below is the implementation of the above approach.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find the probability of reaching all points after N moves from point N
- Reaching a point using clockwise or anticlockwise movements
- Minimum time to reach a point with +t and -t moves at time t
- Number of steps required to reach point (x,y) from (0,0) using zig-zag way
- Minimum steps to come back to starting point in a circular tour
- Find the probability of a state at a given time in a Markov chain | Set 1
- Finding the probability of a state at a given time in a Markov chain | Set 2
- Reflection of a point at 180 degree rotation of another point
- Rotation of a point about another point in C++
- Probability of rain on N+1th day
- Aptitude | Probability | Question 1
- Aptitude | Probability | Question 2
- Aptitude | Probability | Question 3
- Aptitude | Probability | Question 4
- Aptitude | Probability | Question 5
- Aptitude | Probability | Question 6
- Probability of a key K present in array
- Probability of getting more value in third dice throw
- Aptitude | Probability | Question 10
- Probability that two persons will meet
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Mithun Kumar