Data Structures & AlgorithmsModerateProduct-company placement
In how many ways can a convex polygon with 7 vertices be divided into triangles by non-crossing diagonals?
- A. 132
- B. 70
- C. 42
- D. 28
Correct answer: C. 42
Triangulations of a convex (n)-gon are counted by the Catalan number C(n−2) = C(5) = 42 (same as full parenthesisations of a product of 6 factors).
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
- Coins of denominations 1, 2, 8, 10 are available in unlimited supply. What is the minimum number of coins needed to make 16, and how many…
- Heap sort (ascending) is run on [3, 13, 29, 24, 7, 25, 19, 40]: build a max-heap bottom-up, then repeatedly swap the root with the last…
- Dijkstra's algorithm runs from A on the directed graph A→C (4), A→D (15), B→A (2), B→C (13), C→D (8), C→E (7), C→F (2), D→B (12), E→B (7)…
- Floyd–Warshall runs on vertices 1–4 with directed edges 1→2 (2), 1→3 (8), 2→1 (8), 2→4 (3), 3→2 (7), 3→4 (6), 4→1 (2). After the…
- A tree on vertices 1–9 has edges 2–1, 3–2, 4–2, 5–2, 6–5, 7–4, 8–5, 9–7. What are its diameter and radius, and which vertex/vertices form…
- An undirected graph has edges A–E, A–G, A–H, B–H, C–E, D–F, D–H, E–G, F–H, G–H. BFS starts at A and always scans neighbours in…