Data Structures & AlgorithmsModerateTCS NQT · graph colouring
Problem: What is the minimum number of colours needed to colour a bipartite graph so that no adjacent vertices share a colour?
- A. 1
- B. 3
- C. 4
- D. 2
Correct answer: D. 2
A bipartite graph is 2-colourable by its two sides, and any graph with an edge needs at least 2 colours.
More Coding Interview Problems questions
- Problem: Which operation does the 'pointer jumping' technique speed up in parallel algorithms, and what is its complexity?
- Problem: Which problem asks for the number of ways to walk exactly k steps on a graph from u to v?
- Problem: What is the purpose of path compression in a union-find structure?
- Problem: Which structure answers 'number of points in a rectangle' queries offline in O(log n) each using sorting and a Fenwick tree?
- Problem: What is the expected depth of a random binary search tree built from n distinct keys?
- Problem: What is the Hamming distance between 1011 and 1101 in binary?