CS FundamentalsHardGATE CS (PYQ pattern)

A query joins 5 relations R1..R5 and the optimiser considers every possible join tree, including bushy trees, with every distinct arrangement counted (the join operands are ordered, so R1 ⋈ R2 and R2 ⋈ R1 are different trees; cross products are allowed). How many join trees exist?

  1. A. 120
  2. B. 840
  3. C. 1680
  4. D. 3360

Correct answer: C. 1680

The number of binary trees with 5 labelled leaves and ordered children is (2n - 2)! / (n - 1)! = 8! / 4! = 1680. Left-deep trees alone number 5! = 120.

More DBMS and SQL questions

Exams that ask this topic