GATE Computer ScienceVery hardGATE CS (PYQ pattern)
A cyclic binary string of length 12 is written around a circle, so position 12 is followed by position 1. How many of the 2¹² strings contain no three consecutive 0s anywhere around the circle?
- A. 1705
- B. 1499
- C. 1520
- D. 1456
Correct answer: B. 1499
Linear strings without 000 number 1705 (tribonacci-type recurrence), but some of them create 000 across the wrap (e.g. ending 00 and starting 0, or ending 0 and starting 00). Checking all 4096 strings with the wrap-around gives 1499. 1705 ignores the wrap-around.
More Algorithms questions
- What is the maximum possible sum of a non-empty contiguous circular subarray of A = [6, −4, −7, 5, 3, −2, 8, −6, 4, −1] (the array is…
- A 6 × 6 grid is given row by row, where # is a blocked cell: row1 "....#.", row2 "..#...", row3 ".#..#.", row4 "....#.", row5 "#....."…
- Twelve meetings occupy CLOSED time intervals [1,5], [2,6], [5,9], [6,7], [4,8], [7,11], [8,12], [3,10], [9,13], [10,14], [12,15], [13,16]…
- The length of the longest bitonic subsequence (strictly increasing and then strictly decreasing; either part may be empty-length-1) of [4…
- Four greedy rules are proposed for choosing the maximum number of mutually non-overlapping activities: I. repeatedly choose the activity…
- Which of the following statements about the 0/1 knapsack problem is/are correct? I. The O(nW) dynamic programme is polynomial in n and in…