Data Structures & AlgorithmsModerateGATE CS · ICPC regional
Problem: What is the chromatic number of the cycle graph C5 (5 vertices in a single cycle)? The chromatic number is the least number of colours that colour adjacent vertices differently.
- A. 4
- B. 2
- C. 5
- D. 3
Correct answer: D. 3
An odd cycle needs three colours: two colours force a proper alternation that fails on an odd cycle. Assuming two colours suffice is the classic error.
More Coding Interview Problems questions
- Problem: What is the independence number of the cycle graph C7 (the maximum number of vertices with no two adjacent in the 7-cycle)?
- Problem: The binary search tree is built by inserting 8, 3, 10, 1, 6, 14, 4, 7, 13 in this order. How many nodes lie at the maximum depth…
- Problem: A binary tree is given in level order with None for missing children: [1, 2, 3, None, 4, 5, None, 6]. In this array, node at…
- Problem: The right-side view of a binary tree lists the rightmost node at each depth from top to bottom. For the tree with root 1…
- Problem: A binary tree is given by level order [1, 2, 3, 4, 5, None, 6]. Its diameter is the largest number of edges on any path between…
- Problem: How many palindromic substrings of even length does "abbaccdd" contain?