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–D (1), B–D (1), B–E (1), B–F (1), B–G (1), C–D (1), C–G (1), D–E (1), D–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. 5
- B. 6
- C. 3
- D. 4
Correct answer: D. 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
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (5), A–E (2), B–E (2), C–D (6), C–E (3), D–E (6). Among all…
- Bipartite graph with left side {A, B, C}, right side {D, E, F} and edges A–D, A–E, B–F, C–D, C–F. What is the size of a maximum matching…
- A binary trie of 6-bit numbers stores the set S = [12, 44, 27, 7, 63, 30, 48]. For the query x = 39, what is the maximum value of x XOR s…
- Array A = [20, 5, 12, 11, 18, 29, 30, 31, 17]. How many index pairs i < j satisfy (A[i] XOR A[j]) < 9? (A trie with subtree counts answers…
- Undirected graph on vertices A, B, C, D, E, F, G with edges A–B (1), B–C (1), B–D (1), B–F (1), B–G (1), C–D (1), C–F (1), D–G (1), E–F…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (5), A–D (2), B–C (6), C–D (3), C–E (1), D–E (1). Among all…