Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
aa:lab:8 [2025/12/01 19:14] mihnea.gheorghe exercițiu Python |
aa:lab:8 [2025/12/04 12:08] (current) mihnea.gheorghe fix notation consistency |
||
|---|---|---|---|
| Line 26: | Line 26: | ||
| \mathrm{isBSTBetween} : \mathrm{BTree} \times \overline{\mathbb{E}} \times \overline{\mathbb{E}} \to \mathrm{Bool} \\ | \mathrm{isBSTBetween} : \mathrm{BTree} \times \overline{\mathbb{E}} \times \overline{\mathbb{E}} \to \mathrm{Bool} \\ | ||
| \mathrm{isBSTBetween}(\mathrm{Nil}, lo, hi) = \text{true} \\ | \mathrm{isBSTBetween}(\mathrm{Nil}, lo, hi) = \text{true} \\ | ||
| - | \mathrm{isBSTBetween}(\mathrm{Node}(x,l,r), lo, hi) | + | \mathrm{isBSTBetween}(\mathrm{Node}(x,l,r), lo, hi) = (lo \le x \le hi) |
| - | \;\equiv\; | + | |
| - | (lo \le x \le hi) | + | |
| \;\land\; | \;\land\; | ||
| \mathrm{isBSTBetween}(l, lo, x) | \mathrm{isBSTBetween}(l, lo, x) | ||
| Line 95: | Line 93: | ||
| \( | \( | ||
| - | E[L] = \tfrac{n (n + 1)}{2} (H_{n+1} - 1) - 1 | + | E[L] = \tfrac{2 (n + 1)}{n} (H_{n+1} - 1) - 1 |
| - | = \tfrac{n (n + 1)}{2} (\tfrac{1}{2} + \tfrac{1}{3} + \dots + \tfrac{1}{n} + \tfrac{1}{n+1}) -1 | + | = \tfrac{2 (n + 1)}{n} (\tfrac{1}{2} + \tfrac{1}{3} + \dots + \tfrac{1}{n} + \tfrac{1}{n+1}) -1 |
| \) | \) | ||