🚀 **Catalan Numbers & Unique BSTs!** 🌳🧮 Did you know the number of unique Binary Search Trees (BSTs) with `n` nodes can be found using Catalan numbers? Here's how! ### Formula The nth Catalan number is given by: \[ C_n = \frac{1}{n + 1} \binom{2n}{n} \] In Python:
1
0
0
10
0
Download Image
Explanation - Time Complexity: (O(n)) because we iterate `n` times. - Space Complexity: (O(1)) because we're using a constant amount of space to store the interim result.
### Real-World Use Case **Expression Parsing**: Unique BSTs are crucial in compiler design for parsing arithmetic expressions. They help in generating different parse trees for expressions, ensuring that code gets compiled correctly and efficiently.