ProgrammingModerate
A matrix of 10 x 10 is searched linearly for a value. About how many cell reads happen in the worst case?
- A. 10
- B. 100
- C. 20
- D. 1000
Correct answer: B. 100
A linear search may have to check every cell before finding the value or proving it absent, so the worst case is 10 x 10 = 100 reads. 10 checks a single row, and 20 adds the dimensions instead of multiplying.
More C Programming questions
- A 2D array is passed to a function that needs the number of rows. Which argument can it NOT rely on?
- int a[3][3] = {0}; int p = a[1]; p[2] = 7; printf("%d", a[1][2]); What is printed?
- The number of ways to choose a 2 x 2 submatrix in a 4 x 4 matrix (choosing consecutive rows and columns) is what?
- Which of these statements about in-place transposition is correct?
- A table of size 5 uses h(k) = k % 5 with linear probing. Keys 15, 5, 10 and 3 are inserted in that order. How many slots are examined when…
- A hash table of size 5 uses h(k) = k mod 5 with linear probing. The keys 5, 10, 15 and 3 are inserted in that order into an empty table…