fool2fish / dragon-book-exercise-answers

Compilers Principles, Techniques, & Tools (purple dragon book) second edition exercise answers. 编译原理(紫龙书)第2版习题答案。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exercise 3.3.3, subsequences

blueglyph opened this issue · comments

In a string of length n, how many of the following are there?

1. Prefixes.
2. Suffixes.
3. Proper prefixes.
4. ! Substrings.
5. ! Subsequences.

The current solution for the last part of the question is Σ(i=0,n) C(n, i), but it can be simplified as 2^n since each position can be either deleted or not.