2c03-review - 00063

2c03-review - 00063 - Give a recursive (divide and conquer...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
6 8.[10] a[5] If team 1 needs i games to win, then it has won n-i games already. Thus, we obtain the following recurrence: 1 if i=0 and j>0 P(i, j) = 0 if i>0 and j=0 p n-i (P(i-1,j))+(1- p n-i (P(i,j-1))) if i>0 and j>0 b[5] (i,j) 0 1 2 3 4 0 0 0 0 0 0 1 1 0.5 0.25 0.125 0.0625 2 1 0.65 0.37 0.1985 0.1033 3 1 0.79 0.538 0.3343 0.1957 4 1 0.895 0.7165 0.5254 0.36055 9.[10] Solution at the end. 10.[23] We can recursively define the number of combinations of m things out of n , denoted C(n,m), for n = 1 and 0 < m < n, by C(n,m) = 1 if m=0 or m=n, C(n,m) = C(n-1,m)+C(n-1,m-1) if 0<m<n a.[3]
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Give a recursive (divide and conquer idea) function (in a pseudo-code) to compute C(n,m). b.[15] What is the worst case running time for 10(a) as a function of n? c.[3] Give a dynamic programming algorithm to compute C(n,m). Hint. The algorithm constructs a table generally known as Pascals triangle. d.[2] What is the worst case running time for 10(c) as a function of n? Try to be as exact as possible. a. Function RCOMBINATION(n,m):integer begin if m==0 or m==n then begin RCOMBINATION:=1; return; end RCOMBINATION:= RCOMBINATION(n-1,m)+ RCOMBINATION(n-1,m-1); end...
View Full Document

Ask a homework question - tutors are online