Data Structures & AlgorithmsVery hardGATE CS
The boolean expression F & T | 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. 3
- B. 2
- C. 1
- D. 4
Correct answer: B. 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
- What is the maximum flow from S to T in the network with directed capacities A→C (5), B→A (10), B→C (13), B→T (9), C→T (12), S→A (14), S→B…
- 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…
- 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…