Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2 B
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 is the size of a maximum independent set (a largest set of vertices with no edge between any two of them)?
- A. 5
- B. 4
- C. 6
- D. 3
Correct answer: B. 4
Exhaustive search over subsets gives 4. Picking the currently lowest-degree vertex and deleting its neighbourhood (a common heuristic) gives 3, and n minus the maximum matching gives 4, which is not a general identity.
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
- 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…
- A connected undirected graph has the vertices E, F, I, Q, S, Z and weighted edges (weights in brackets): E–I (3), F–E (8), Z–S (12), S–I…
- A directed weighted graph has the arcs u→v (weight): Z→G (12), G→Z (1), G→T (11), G→A (3), G→S (7), T→Z (11), T→M (1), A→Z (13), A→T (11)…
- 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…
- An undirected connected graph on the vertices B, M, Q, R, U has the edges B–U, M–R, Q–R, M–Q, B–R, B–M, Q–U, B–Q. How many spanning trees…