Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2
Undirected graph on vertices A, B, C, D, E, F, G with edges A–B (1), B–C (1), B–D (1), B–F (1), B–G (1), C–D (1), C–F (1), D–G (1), E–F (1), E–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. 5
- B. 4
- C. 6
- D. 3
Correct answer: B. 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
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (5), A–D (2), B–C (6), C–D (3), C–E (1), D–E (1). Among all…
- Keys are inserted in the order 88 50 42 89 48 68 into an empty binary search tree. Then the key 88 (which has two children) is deleted by…
- A binary tree with distinct letters has preorder DEFACB and inorder FAECDB. What is its postorder traversal (left, right, root), written…
- Dictionary D = {ada, ats, emd, lsc, pcd, pmd, pmo, pno, pnr, rbs, sbp, ssr} (all words have 3 letters). Starting from the word 'ptd', a…
- Complete undirected graph on vertices A to F with symmetric edge weights given row by row (row i, column j = weight of edge between…
- Array A = [29, 1, 24, 26, 13, 6, 8] (all values below 32). What is the maximum of A[i] XOR A[j] over all index pairs with 0 ≤ i < j < 7?