Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS
An undirected graph has the vertices H, K, N, T, U, X and the edges X–H, X–U, X–K, H–K, N–T, N–U, N–K, U–K. What is its chromatic number, the least number of colours needed to colour the vertices so that adjacent vertices differ?
- A. 3
- B. 5
- C. 2
- D. 4
Correct answer: A. 3
Searching colour counts from 1 upward finds 3 colours suffice and one fewer does not. Greedy colouring in label order uses 3, and the maximum degree bound gives 5; the clique number 3 is only a lower bound.
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
- Consider this function: python def g(n): if n < 3: return n if n % 2 == 0: return g(n - 3) + g(n - 3) return g(n - 1) - 1 What value does…
- A four-wheel combination lock shows four digits 0–9 on wheels that wrap around (9 goes to 0 and 0 goes to 9). One move turns one wheel by…
- A tree has vertices D, I, K, N, O, R, T, Y and weighted edges (weights in brackets): Y–T (4), Y–I (2), Y–O (8), Y–K (3), O–N (5), O–R (7)…
- An undirected graph has the vertices C, O, Q, W, X, Z and the edges X–Q, Q–C, Q–O, W–C, X–C, O–Z, Q–Z, C–O, X–Z. What is the minimum…
- An undirected graph has the vertices C, G, T, W, X and the edges C–T, C–G, W–T, W–G, W–X, T–G, G–X. A walk may repeat vertices and edges…
- A grid has 6 rows and 6 columns (top to bottom; '.' open, '#' blocked): ..#... .....# .##... ...... ..#..# ...... You may only move right…