Data Structures & AlgorithmsHardICPC regional · GATE CS
Problem: What is the independence number of the cycle graph C7 (the maximum number of vertices with no two adjacent in the 7-cycle)?
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
Pick vertices with gaps of at least two around the cycle. For an odd cycle of length 7 the best is floor(7/2) = 3, since 4 vertices would force two neighbours together.
More Coding Interview Problems questions
- 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?
- Problem: The string "aaaa" can be written as a concatenation of the pieces "a" and "aa" in several ways (order matters). How many such…