Data Structures & AlgorithmsVery hardGATE CS · TCS NQT
How many binary strings of length 5 contain no two consecutive zeros?
- A. 14
- B. 13
- C. 15
- D. 17
Correct answer: B. 13
The count follows the Fibonacci numbers: each string ends in 1 (any valid string of length 4) or in 01 (valid of length 3). This gives 13.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the lexicographically smallest string obtainable from cbad by swapping exactly one pair of characters?
- How many integers x in [1, 100] are divisible by 3 and have a reversed digit string also divisible by 3?
- What is the sum of all divisors of 36 (sigma function)?
- How many unordered pairs {a, b} with 1 <= a < b <= 12 have a + b divisible by 4?
- What is the product of all positive divisors of 36?
- A robot starts at (0, 0) and performs the moves L, U, R, R, D, D, L, U, U, R, R. Moves L/R change x, U/D change y. What is the Manhattan…