Consider: A. The number of labelled binary trees possible with n nodes is (2n)!/(n + 1)!. B. The number of binary search trees possible with n nodes is (2n)!/((n + 1)! n!). C. The number of unlabelled binary trees possible with n nodes is C(2n, n)/(n + 1)!. D. The number of simple, undirected, labelled graphs possible with n vertices is 2^(n(n−1)/2).
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: B. (A, B) and (D) are only correct
Explanation
Unlabelled binary trees (and BSTs) number the Catalan number C(2n,n)/(n + 1) = (2n)!/((n + 1)! n!), so B is true and C (dividing by (n + 1)!) is false. Labelled trees multiply the Catalan number by n!: (2n)!/(n + 1)! (A true). Each of the C(n,2) possible edges is present or not: 2^(n(n−1)/2) (D true).
More Data Structures and Algorithms questions
- Which of the following are correct about Hamiltonian problems? A. The Hamiltonian cycle problem is NP-complete. B. If G is an undirected bi…
- For matrix multiplication with a simple divide-and-conquer algorithm: A. the running time is T(n) = Θ(n³) B. the running time is T(n) = Θ(n…
- Match List I with List II
- Match List I with List II
- What is the maximum value of items you can carry if maximum weight allowed is 25 with a fractional knapsack?
- If new item is added to the list, total items is 8 and capacity is 25 , then the best-case time of fractional knapsack for this case is ___…