Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose the Blazers were to get to the NBA Finals and play the Cavaliers. In ord

ID: 3828737 • Letter: S

Question

Suppose the Blazers were to get to the NBA Finals and play the Cavaliers. In order to win the championship, one team must win 4 games. We will assume that, for any given game, each team is as likely as the other to win.

Let’s define the probability of the Blazers winning the championship as PBlazers(i,j) where i is the number of games the Blazers need to win to win the championship and j is the number of games the Cavaliers need to win to win the championship. Thus, PBlazers(i,0) = 0.0 for all i > 0 (i.e., the Cavaliers have won 4 games, need to win 0 more, and thus the Blazers can not win the championship) and PBlazers(0,j) = 1.0 for all j > 0 (i.e., the Blazers have won 4, need to win 0 and thus have won the championship).

More generally, PBlazers(i,j) must be the average of the probability that the Blazers win the next game (i.e., PBlazers(i - 1,j)) plus the probability that the Blazers don’t win the next game (i.e., PBlazers(i,j - 1)). For example, if the Blazers have won two games and the Cavaliers one, then we would find PBlazers(2,3)= 11/16.

So we have the following recursive statement of this function:

PBlazers(i,j) = 1.0 if i = 0 and j > 0

                 = 0.0 if i > 0 and j = 0

                   = (PBlazers(i - 1,j) + PBlazers(i,j - 1)) / 2.0

Please:
Create a 5 x 5 table that contains the probability for PBlazers(i,j) where i and j range from 0-4 based on the recursive definition above.

Implement an efficient method in Java:

double computeOddsNeeding(int us , int them) { . . . }

to solve this problem for any values of i (us) and j (them).

List the complexity of your implementation in both time and space?

Note: cannot further expand on the problem explanation. All information provided is written here.

Explanation / Answer

PROGRAM CODE:

package simple;

public class Probability {

   public static double computeOddsNeeding(int us , int them)

   {

       if(us==0 && them==0)

           return 0.0;

       else if(us==0 && them > 0)

           return 1.0;

       else if(us > 0 && them == 0)

           return 0.0;

       else return (computeOddsNeeding(us-1, them) + computeOddsNeeding(us, them-1))/2.0;

   }

  

   public static void main(String[] args) {

       double table[][] = new double[5][5];

       for(int i=0; i<5; i++)

       {

           for(int j=0; j<5; j++)

           {

               table[i][j] = computeOddsNeeding(i,j);

               System.out.printf("%.2f", table[i][j]) ;

               System.out.print(" ");

           }

           System.out.println();

       }

   }

}

OUTPUT:

0.00 1.00 1.00 1.00 1.00

0.00 0.50 0.75 0.88 0.94

0.00 0.25 0.50 0.69 0.81

0.00 0.13 0.31 0.50 0.66

0.00 0.06 0.19 0.34 0.50

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote