a) No, first one is incorrect because both the for-loops are independent. The first for loop iterates for N times, whereas the second for-loop iterates for 1000000000*M times.
If f1(n) = O(g1(n)) and f2(n) = O(g2(n)), then f1 + f2 = O(|g1| + |g2|).
Check this Wikipedia link on Big O notation to know why the above.
So, overall time complexity = O(|N| + |M|).
b) The nested loop's time complexity comes out to be 1 + 2 + ... + N = N * (N+1)/2 = O(N2).
And, k-variable guided loop's complexity is O(N).
So, overall time complexity in this case is O(N2).
c) The 3rd case is somewhat complex.
When N = 2, the total iteration of both-loops = 0.
When N = 3, the total iteration of both-loops = 2.
When N = 4, the total iteration of both-loops = 2 + 6 = 8.
When N = 5, the total iteration of both-loops = 2 + 8 + 12 = 22.
...
When N = N(equals), the total iteration of both-loops = 2 + 8 + 22 + ... + (N-1)*(N-2) =
So, the total complexity
= 2 + 8 + 22 + ... + (N^2 - 3*N + 2)
= 1/3 * (N-2) * (N-1) * N
Check this link to know how it was derived
= O(N^3).
So, overall time complexity = O(N3).