ProgrammingHardTCS NQT · Infosys
The sorted array is {1, 3, 3, 3, 7, 9}. What is the index of the first element that is at least 4?
- A. 3
- B. 5
- C. 4
- D. 6
Correct answer: C. 4
Index 4 holds 7, the first value not less than 4. Indices 0 to 3 hold 1, 3, 3, 3, all smaller than 4.
More C Programming questions
- A qsort comparator compares double values with (x > y) - (x < y). After sorting {2.5, -1.0, 2.25}, which value is last?
- Merge sort merges two halves with n element comparisons, so T(n) = 2T(n/2) + n and T(1) = 0. What is T(8)?
- unsigned int x = 1u; x = ~x; What is x?
- unsigned int u = 5u; int s = -5; printf("%s", (u + s == 0) ? "yes" : "no"); What is printed?
- uint32t mask = 0; for (int i = 0; i <= 30; i += 3) mask |= 1u << i; How many set bits does mask have?
- unsigned int v = (unsigned int)(-2); printf("%X", v); What is printed?