Data Structures & AlgorithmsHardCodeforces Div 2 · ICPC regional
Undirected graph on vertices A, B, C, D, E, F with edges A–C (1), A–D (1), A–E (1), B–D (1), B–F (1), C–D (1), C–F (1), D–E (1), D–F (1), E–F (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. 3
- C. 6
- 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
- 2 × 3 sliding puzzle with tiles 1 to 5 and one blank (shown as ). Current board: 4 1 / 2 5 3. Goal board: 1 2 3 / 4 5 . A move slides a…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (1), A–C (2), A–E (2), B–C (2), C–D (1), C–E (3). How many distinct…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (3), A–C (3), B–C (3), B–D (3), C–D (1), C–E (4). Among all…
- Connected undirected graph on vertices A, B, C, D, E, F, G, H with edges A–D (1), A–E (1), B–D (1), B–E (1), B–G (1), C–D (1), C–H (1)…
- A binary tree with distinct letters has preorder FBGCHAED and inorder GHACBDEF. What is its postorder traversal (left, right, root)…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (15), A–C (13), A–D (20), B–D (20), B–E (17), C–D (4), C–E…