Data Structures & AlgorithmsHardCodeforces Div 2 · ICPC regional
Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–C (1), B–D (1), B–G (1), C–D (1), C–E (1), D–E (1), E–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. 3
- B. 7
- C. 4
- D. 5
Correct answer: A. 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
- Keys [7, 34, 44, 32, 10, 49, 20] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right…
- Connected undirected graph on vertices A, B, C, D, E, F, G with edges A–E (1), A–G (1), B–F (1), C–D (1), D–F (1), E–F (1), E–G (1)…
- Coins of denominations [12, 10, 3, 2] are available in unlimited quantity. What is the minimum number of coins needed to pay exactly 30?…
- A binary trie of 6-bit numbers stores the set S = [52, 29, 43, 11]. For the query x = 29, what is the maximum value of x XOR s over all s…
- Undirected graph on vertices A, B, C, D, E, F, G with weighted edges A–B (6), A–G (9), B–C (6), B–G (8), C–D (6), C–F (1), D–G (8), E–F…
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–D (1), A–G (1), B–E (1), C–D (1), C–F (1), C–G (1), D–E (1), D–F (1)…