Question: plz write a better pseudocode then explain Algorithm 2 RANDDISCRETE2(P) 1: F new n-element array 2: F[0] P[O] 3: for + 1 to n -
plz write a better pseudocode then explain

![F new n-element array 2: F[0] P[O] 3: for + 1 to](https://s3.amazonaws.com/si.experts.images/answers/2024/08/66cdedf239232_82566cdedf1d5a98.jpg)
Algorithm 2 RANDDISCRETE2(P) 1: F new n-element array 2: F[0] P[O] 3: for + 1 to n - 1 do 4: F[]+F[ j - 1] +PG] 5: r+ RANDO 6: r0 7: while r > Fu do 8: + +1 9: return (d) Write, in pseudocode, a linear-time algorithm RANDDISCRETE3 for this computational problem that takes an array P of n elements as input and outputs a random integer consistent with a discrete random variable with integer values 0,1,...,n - 1 according to the probability mass function encoded by P and that uses a constant amount of space. Is this algorithm better than the algorithm you recommended to implement in the previous part of this problem? Please explain briefly
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
