Smart City

ADA midterm - 3

(a) : normal

DP[n][m] =

min(

DP[n-1][m]+W(n-1,m,(+1,0),DP[n-1][m]),

DP[n][m-1]+W(n,m-1,(0,+1),DP[n][m-1])

)

DP[n][m] =

1+min(

DP[n-1][m]+W(n-1,m,(+1,0),DP[n-1][m]),

DP[n][m-1]+W(n,m-1,(0,+1),DP[n][m-1])

)

(if n > 1)

(if m > 1)

Base Case

DP[0][0] = 0

Answer

DP[n][m]

(b) : violate no more than k tickets

DP[n][m][k] =

min(

DP[n-1][m][k]+W(n-1,m,(+1,0),DP[n-1][m]),

DP[n][m-1][k]+W(n,m-1,(0,+1),DP[n][m-1]),

DP[n][m-1][k-1], DP[n-1][m][k-1],

)

DP[n][m][k] =

1+min(

DP[n-1][m][k]+W(n-1,m,(+1,0),DP[n-1][m]),

DP[n][m-1][k]+W(n,m-1,(0,+1),DP[n][m-1]),

DP[n][m-1][k-1], DP[n-1][m][k-1],

)

(if n > 1)

(if m > 1)

(if m > 1 and k > 1)

(if n > 1 and k > 1)

Base Case

DP[0][0][*] = 0

Answer

DP[n][m][k]

Grading Criteria

(c) : synchronized traffic lights with greedy choice

According to random d if all green ...

Counter-example

Time
0 0 0
1 100 0
2 99 0
3 98 0
4 97 0
5 96 0
... ... ...

Grading Criteria

Misunderstanding

Common flaws

Made with Slides.com