ProgrammingHardGATE CS · Campus placements
How many binary strings of length 4 contain at least two adjacent 1s?
- A. 6
- B. 8
- C. 10
- D. 4
Correct answer: B. 8
There are 16 strings in total, and 8 of them contain no two adjacent 1s (the Fibonacci count F(6) = 8). So 16 - 8 = 8 strings have at least one adjacent pair.
More C Programming questions
- How many subsets of {1, 2, ..., 10} have an even sum of elements? The empty set counts.
- The pairs (1,2), (3,5) and (2,5) are sorted by the second value descending, with ties broken by the first value ascending. Which pair…
- How many integers from 0 to 255 have exactly four 1 bits in binary?
- What is 0 ^ 1 ^ 2 ^ ... ^ 31, the XOR of all integers from 0 to 31?
- What is the total number of 1 bits in the binary forms of 1, 2, ..., 16 added together?
- uint16t s = 0; for (int i = 1; i <= 1000; i++) s += i; What is s at the end?