Data Structures & AlgorithmsHardICPC regional · GATE CS top band
Undirected graph on vertices A, B, C, D, E, F, G with edges A–C (1), A–E (1), A–F (1), B–E (1), B–F (1), B–G (1), C–E (1), D–E (1), E–G (1), F–G (1) (weights ignored). Vertices are coloured in the order A, B, C, … each with the smallest-numbered colour (0, 1, 2, …) not used by an already coloured neighbour. How many colours does this greedy colouring use?
- A. 3
- B. 4
- C. 5
- D. 6
Correct answer: B. 4
Greedy colouring in this vertex order uses 4 colours, while the chromatic number is 3. Confusing the order-dependent greedy result with the optimal value is the mistake.
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
- Words ['dbd', 'cc', 'bb', 'aca', 'bda', 'ccd'] (each may be used at most once). A chain is a sequence of these words in which the first…
- Distinct words ['ccc', 'cb', 'ac', 'ba', 'cbb', 'cca'] are inserted into an empty trie (one node per character, shared prefixes share…
- Distinct keys [13, 25, 27, 11, 8, 16] are inserted, in the order given by the sequence [25, 13, 8, 27, 16, 11], into an empty binary…
- Words ['c', 'cbca', 'bbaa', 'a', 'c', 'cca', 'cca'] are inserted in this order into an empty trie with one node per character, shared…
- Undirected graph on vertices A, B, C, D, E, F with weighted edges A–B (5), A–C (6), A–D (4), A–F (3), B–D (8), B–E (5), B–F (6), C–F (6)…
- Array A = [27, 21, 20, 5, 13, 9, 28] (all values below 32). What is the maximum of A[i] XOR A[j] over all index pairs with 0 ≤ i < j < 7?