Compute cache miss rate for the given code
As the cache is 4 doubles, for m=1, after accessing A[0], there are in the cache A[0]...A[3]. So next access A[1] is a hit and it is the same for A[2] and A[3]. Only access A[4] will be a miss. Hence miss rate is 0.25

For m=2, After accessing A[0], the cache holds the same line. Next access is A[2] which is a hit, and A[4] is a miss and so on. So miss rate is 0.5. Note that total cache size is 8 doubles. So when accessing A[8], cache line 0 is cleared and when A[1] will be accessed on later iterations, it will be again a miss.

For m=16 and n=2, one needs to look closely at the access patterns. Also do not forget that the cache is associative with two lines. 

iteration 1 i=0, j=0 ->       A[0]  miss in line 0
iteration 2 i=0, j=1 16j+i -> A[16] miss in line 1
iteration 3 i=1, j=0 16j+i -> A[1]  hit in line 0 (because cache is 2 ways associative)
iteration 4 i=1, j=1 16j+i -> A[17] hit in line 1  

and all access will be hits until iteration 8 (i=4, j=0). In that case, we access  A[4] that isn't in any cache and we restart a new cycle. So we have 2 misses for 8 iteations and miss rate is 0.25