Data Structures & AlgorithmsHardICPC regional · GATE CS top band
Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–D (1), A–F (1), A–G (1), B–G (1), C–F (1), C–G (1), D–E (1), D–F (1), E–G (1) (weights ignored). What is the length, counted in edges, of the shortest cycle with an odd number of edges?
- A. 4
- B. 6
- C. 7
- D. 3
Correct answer: D. 3
Enumerating simple cycles gives shortest odd length 3; the shortest even cycle is 4 and the parity condition is what separates them.
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
- Array A = [26, 14, 21, 19, 25, 20] (all values below 32). What is the maximum of A[i] XOR A[j] over all index pairs with 0 ≤ i < j < 6?
- Keys are inserted in the order 12 48 72 44 38 26 into an empty binary search tree. Then the key 48 (which has two children) is deleted by…
- Words ['bcb', 'cacb', 'bbba', 'bcb', 'cbaa', 'b', 'abcc'] are inserted in this order into an empty trie with one node per character…
- Complete undirected graph on vertices A to F with symmetric edge weights given row by row (row i, column j = weight of edge between…
- A binary trie of 6-bit numbers stores the set S = [45, 4, 46, 21]. For the query x = 48, what is the maximum value of x XOR s over all s…
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–B (1), A–C (1), A–G (1), B–G (1), C–D (1), C–F (1), C–G (1), D–E (1)…