GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Of the 92 solutions of the 8-queens problem (rotations and reflections counted separately), how many have no queen on either of the two main diagonals of the board?
- A. 92
- B. 28
- C. 8
- D. 12
Correct answer: D. 12
Enumerating all 92 solutions by backtracking and discarding any with a queen at (r, r) or (r, 7 − r) leaves 12. Excluding only one main diagonal leaves 28.
More Algorithms questions
- Four men m0–m3 and four women w0–w3 have preference lists (best first) m0: w1 w0 w2 w3; m1: w0 w2 w1 w3; m2: w1 w3 w2 w0; m3: w0 w1 w3 w2…
- For n = 5 distinct keys, let M be the worst-case comparisons of top-down merge sort (split ⌈n/2⌉ + ⌊n/2⌋, merge stops when one side is…
- What is the minimum number of comparisons that guarantees finding the median (the third smallest) of 5 distinct elements in the worst case?
- A hash table with chaining has m = 50 slots and stores n = 200 keys; each key is equally likely to be in any slot (simple uniform…
- Twenty distinct keys are hashed independently and uniformly into 100 slots. What is the expected number of keys that share their slot with…
- The closed intervals [1,4], [2,6], [3,5], [7,10], [8,12], [9,11], [13,15], [5,8], [10,14], [0,2] are given. What is the minimum number of…