Data Structures & AlgorithmsHardICPC regional · GATE CS top band
A binary trie of 6-bit numbers stores the set S = [25, 51, 62, 29]. For the query x = 53, what is the maximum value of x XOR s over all s in S? (Answer as a decimal integer.)
- A. 44
- B. 11
- C. 52
- D. 6
Correct answer: A. 44
A greedy walk down the trie that prefers the opposite bit at every level finds the maximum 44. Only checking the largest stored element, or picking the smallest XOR, are the usual slips.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Directed graph on vertices A, B, C, D, E, F, G with edges C→F, F→G, F→E, A→D, E→C, C→G, B→F, A→G, B→C, G→C, A→E. How many strongly…
- On an 7 × 7 chessboard with rows and columns numbered 0 to 6, a knight starts at (0, 0) and must reach (5, 1) (as (row, column)). A knight…
- A trie keeps a counter at each node, and every word of the list W = ['ab', 'acc', 'aac', 'bcaa', 'cab', 'ab', 'a'] is inserted once per…
- Array A = [22, 11, 12, 9, 20, 23, 25, 15, 2]. How many index pairs i < j satisfy (A[i] XOR A[j]) < 21? (A trie with subtree counts answers…
- Array A = [17, 0, 16, 23, 30, 19, 8, 11, 10]. How many index pairs i < j satisfy (A[i] XOR A[j]) < 13? (A trie with subtree counts answers…
- Points A(6,3), B(8,7), C(3,7), D(9,2), E(3,6), F(0,4) in the plane. The cost of joining two points is the Manhattan distance |x1−x2| +…