Data Structures & AlgorithmsHardTCS Digital · Infosys pattern
A connected undirected graph has vertex degrees A: 3, B: 4, C: 2, D: 3, E: 2. Does it have an Euler path (using every edge exactly once), and if so, where must it start?
- A. Yes, at any vertex
- B. No, B has degree 4
- C. Yes, at A or D
- D. No, there are odd-degree vertices
Correct answer: C. Yes, at A or D
A connected graph has an Euler path iff it has 0 or 2 odd-degree vertices. Here exactly A and D are odd, so an Euler path exists and must start at one of them and end at the other. With 0 odd vertices you could start anywhere (Euler circuit); even degrees like B's 4 never block it.
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
- Houses in a row hold [3, 2, 7, 10, 1, 9]. No two ADJACENT houses may both be chosen. What is the maximum total? (dp[i] = max(dp[i − 1]…
- The set [3, 9, 7, 3, 11] is split into two subsets so that the absolute difference of their sums is as small as possible (subset-sum DP…
- Digits map to letters A = 1 … Z = 26. In how many ways can the string '2263' be decoded? (dp over prefixes; a pair counts only if it is…
- Keys 50, 30, 20, 10, 40, 70, 60 are inserted into an empty BST. An iterative inorder traversal pushes nodes while walking left and pops to…
- A course plan has prerequisites (a → b means a must come before b): 1→3, 2→3, 3→5, 4→5, 5→6, 2→4, 6→7. Any number of courses with all…
- Flights (directed, cost): 0→1 100, 1→2 100, 2→3 100, 0→2 500, 1→3 600, 0→3 900. What is the cheapest cost from 0 to 3 using AT MOST 1…