Data Structures & AlgorithmsVery hardGATE CS · Product-company placement
The boolean expression F & F & T ^ T (T = true, F = false, & = AND, | = OR, ^ = XOR) can be fully parenthesised in 5 ways. In how many of them does it evaluate to true?
- A. 2
- B. 3
- C. 1
- D. 4
Correct answer: A. 2
Split at each operator and combine (true, false) counts of the two sides: & needs both true, | fails only if both false, ^ needs them to differ. The full expression gives 2 true and 3 false out of 5.
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
- Keys 60, 41, 30, 69, 50, 54, 52, 55, 21 are inserted in that order into an empty AVL tree. What is the preorder traversal of the final tree?
- The weighted undirected graph A–B (1), A–C (6), A–E (3), B–D (1), C–D (2), C–E (5), D–E (3) has repeated weights. How many different…
- The words stem, stack, step, star, start are inserted into an empty trie (one node per character, shared prefixes share nodes, plus a…
- What is the maximum flow from S to T in the network with directed capacities A→B (15), A→T (2), B→T (10), C→A (2), C→B (13), C→T (9), S→B…
- Symbols occur with frequencies 18, 23, 24, 28, 34, 35. How many bits does an optimal (Huffman) prefix code need for the whole message, and…
- How many topological orderings does the DAG on vertices A–F with edges A→C, B→D, D→C, E→C, F→A, F→C have?