GATE Computer ScienceModerateGATE CS (PYQ pattern)
12-bit sets are stored as bit vectors: A = 101101101101, B = 011010110011, C = 111000011010 (most significant bit first). What are the cardinalities of (A | B) & ~C and of (A ^ B) & C, in that order?
- A. 7 and 5
- B. 6 and 7
- C. 5 and 6
- D. 6 and 5
Correct answer: D. 6 and 5
A | B = 111111111111 and ~C = 000111100101, so (A | B) & ~C = 000111100101 with 6 ones. A ^ B = 110111011110; ANDing with C leaves 110000011010, 5 ones.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- int f(int a[], int l, int r) { if (l == r) return a[l]; int m = (l + r) / 2; int x = f(a, l, m), y = f(a, m + 1, r); return x > y ? x : y…
- Keys 50, 30, 70, 20, 40, 60, 80, 10, 35, 45, 65, 85, 5, 15, 32, 38, 90 are inserted in this order into an empty BST (root at depth 0)…
- A min-heap is built from [27, 5, 19, 3, 41, 8, 16, 2, 33, 11, 24, 7] by bottom-up heapify, and then extract-min (last element to the root…
- int m[4][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}; for (int i = 0; i < 4; i++) for (int j = 0; j < i; j++) {…
- A routine reverses the entire string in place and then reverses each maximal run of non-space characters in place. It is applied twice in…
- A singly linked list 1 -> 2 -> ... -> 20 undergoes two passes: first every 3rd node (by current position) is deleted, then in the…