Data Structures & AlgorithmsHardGATE CS · ICPC regional
Undirected graph on vertices A, B, C, D, E, F, G with edges A–D (1), A–E (1), A–G (1), B–C (1), B–F (1), B–G (1), D–F (1), D–G (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. 4
- B. 3
- C. 5
- D. 6
Correct answer: A. 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
- Array A = [9, 1, 6, 12, 6, 8]. Over all non-empty contiguous subarrays, what is the maximum value of the XOR of the elements in the…
- Rooted tree with root 0 and vertices 0 to 7; the edges are 0–1, 1–2, 1–3, 1–4, 3–5, 2–6, 4–7 (parent–child). Every edge has length 1. What…
- Undirected weighted graph on vertices A, B, C, D, E; its edges, in this listed order, are: D–E (3), C–E (3), A–C (2), B–C (1), A–E (8)…
- Bipartite graph with left side {A, B, C, D}, right side {E, F, G, H} and edges A–E, A–F, C–H, D–F. What is the size of a maximum matching…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (8), A–C (3), A–D (6), A–E (2), B–D (1), B–E (6), C–D (1), C–E (2), D–E…
- 2 × 3 sliding puzzle with tiles 1 to 5 and one blank (shown as ). Current board: 4 2 3 / 5 1. Goal board: 1 2 3 / 4 5 . A move slides a…