Practice Questions on Time Complexity Analysis
Prerequisite: Analysis of Algorithms1. What is the time, and space complexity of the following code: CPPint a = 0, b = 0; for (i = 0; i < N; i++) { a = a + rand(); } for (j = 0; j < M; j++) { b = b + rand(); } Javaint a = 0, b = 0; for (i = 0; i < N; i++) { a = a + Math.random(); } for (j =