ProgrammingModerate
A program uses a 2D table of size 1000 x 1000 with an O(1) update per cell and 1000 passes. How many cell updates are done?
- A. 10^6
- B. 2 x 10^6
- C. 10^9
- D. 10^12
Correct answer: C. 10^9
There are 10^6 cells updated in each of the 1000 passes, which is 10^9 updates.
More C Programming questions
- The number of comparisons a merge of two sorted arrays of sizes 4 and 6 makes in the worst case is at most?
- struct P { int a[3]; }; struct P p = {{1, 2, 3}}; struct P q = &p; printf("%d", (q->a + 2)); What is printed?
- char words[] = {"ab", "cd", "ef"}; char pp = words + 1; printf("%s", pp + 1); What is printed?
- int a[] = {10, 20, 30}; int p = a; p++; printf("%d", p + p[1]); What is printed?
- int x = 1, y = 2; int p = &x, pp = &p; pp = &y; printf("%d %d", x, p); What is printed?
- int inc(int n) { return n + 1; } int dbl(int n) { return n 2; } int (f[2])(int) = {inc, dbl}; printf("%d", f[1](f[0](3))); What is printed?