Data Structures & AlgorithmsHardTCS NQT · ICPC regional
Problem: The bit pattern 10110 is shifted left by 2 positions and then XOR-ed with the original pattern. What is the decimal value of the result?
- A. 88
- B. 78
- C. 94
- D. 19
Correct answer: B. 78
10110 << 2 = 1011000 (88), and 88 ⊕ 22 = 1001110 = 78. Stopping after the shift gives 88, OR gives 94, and shifting right instead gives 22 ⊕ 5 = 19.
More Coding Interview Problems questions
- Problem: Vertices 0–4 have undirected edges 0-1 (3), 1-2 (1), 2-3 (4), 3-4 (2), 0-4 (6), 1-4 (5). A path's cost is the sum of its edge…
- Problem: A directed graph has vertices 0–3 with arcs 0→1, 1→2, 2→1, 2→3. Using DFS from vertex 0 with children visited in increasing…
- Problem: Tree with root 1 and children 1: [2, 3], 2: [4, 5], 4: [6]. What is the number of nodes in the subtree of node 2 (node 2 counts…
- Problem: The string "abracadabra" contains the substring "abra" at several positions. How many occurrences of "abra" are there (overlaps…
- Problem: The string "abcdefghij" is split into blocks of length 4 from the left (the last block may be shorter). How many blocks have…
- Problem: The number of permutations of the digits 1, 2, 3, 4 in which the digit 1 is not in the first position and 4 is not in the last…