Data Structures & AlgorithmsHardCodeforces Div 2 C · GATE CS
An undirected graph has the vertices F, J, M, S, Z and the edges Z–F, Z–J, S–F, S–M, S–J, F–J. What is its chromatic number, the least number of colours needed to colour the vertices so that adjacent vertices differ?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 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 4; 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 < 2: return n if n % 2 == 0: return g(n - 1) + g(n - 3) return g(n - 3) - 1 What value does…
- Consider this recursive function: python def f(n): if n <= 1: return f(n - 1) if n % 3 == 0: f(n - 2) How many times is f called in total…
- Consider this function: python def g(n): if n < 3: return n if n % 2 == 0: return g(n - 3) + g(n - 4) return g(n - 3) - 1 What value does…
- An undirected graph has the vertices G, J, K, M, P, U, V, W and the edges W–U, W–J, W–M, W–G, U–V, U–M, V–K, J–G, K–G, P–M, P–G, M–G. What…
- A grid has 8 rows and 7 columns (rows listed top to bottom; '.' is an open cell, '#' a wall): ..#.... .#..... ..#.##. .#....# .#…
- Floyd–Warshall runs on vertices 1 to 5 with these arcs u→v (weight): 1→2 (4), 1→3 (1), 2→3 (11), 2→4 (2), 2→5 (2), 3→1 (6), 3→2 (4), 4→2…