GATE Computer ScienceHardGATE CS (PYQ pattern)
An undirected graph has edges 1-2, 2-3, 3-4, 4-5, 5-6, 6-1, 2-7, 7-8, 8-9, 9-7, 4-10, 10-11. Vertices are coloured by the parity of their BFS distance from vertex 1. How many edges join two vertices of the same colour (i.e. are monochromatic)?
- A. 2
- B. 1
- C. 3
- D. 0
Correct answer: B. 1
The hexagon 1-2-3-4-5-6 is an even cycle and is properly coloured, but the triangle 7-8-9 is an odd cycle, so any 2-colouring (BFS parity included) must leave exactly 1 of its edges monochromatic.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- int range(Node n, int lo, int hi) { if (!n) return 0; int c = (lo <= n->k && n->k <= hi); if (lo < n->k) c += range(n->l, lo, hi); if…
- Keys 50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 85, 5, 22, 33, 38 are inserted in this order into an empty BST, and every…
- bool f(Node n) { if (!n) return true; if (n->l && n->l->k > n->k) return false; if (n->r && n->r->k < n->k) return false; return f(n->l)…
- In the BST obtained by inserting 40, 20, 60, 10, 30, 50, 5, 15, 3, 1, 25, 55, 57, 56 in order, how many nodes have a balance factor…
- A binary tree is stored in level order with null children written as : 1 2 3 4 5 6 7 8 (a null child still consumes a slot only if its…
- Non-negative numbers are stored as singly linked lists of digits with the least significant digit first. A = 9 -> 9 -> 8 -> 5 (the number…