- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hi! (Wave)
According to my notes:
$$T(n)=T\left(\frac{n}{2} \right)+T\left(\frac{n}{4} \right)+T\left(\frac{n}{8} \right)+n$$
Th recursion tree is this:
https://www.physicsforums.com/attachments/3626
Cost per level $i \to \left( \frac{7}{8} \right)^{i-1}n, i \geq 1$
Leaf per level $i \to 3^i, i \geq 0$
$$\text{Total Cost=} 3^D O(1)+ \sum_{i=1}^D \left ( \frac{7}{8}\right)^{i-1} n$$
$$\frac{n}{2^D}=1 \Rightarrow D=\log_2 n$$
Could you explain me why we have to add $3^D$ at the sum of costs of the levels, in order to find the total cost? Also, why do we find $D$, from $\frac{n}{2^i}=1$ and not for example from $\frac{n}{4^i}=1$ or from $\frac{n}{8^i}=1$ ? (Worried)
According to my notes:
$$T(n)=T\left(\frac{n}{2} \right)+T\left(\frac{n}{4} \right)+T\left(\frac{n}{8} \right)+n$$
Th recursion tree is this:
https://www.physicsforums.com/attachments/3626
Cost per level $i \to \left( \frac{7}{8} \right)^{i-1}n, i \geq 1$
Leaf per level $i \to 3^i, i \geq 0$
$$\text{Total Cost=} 3^D O(1)+ \sum_{i=1}^D \left ( \frac{7}{8}\right)^{i-1} n$$
$$\frac{n}{2^D}=1 \Rightarrow D=\log_2 n$$
Could you explain me why we have to add $3^D$ at the sum of costs of the levels, in order to find the total cost? Also, why do we find $D$, from $\frac{n}{2^i}=1$ and not for example from $\frac{n}{4^i}=1$ or from $\frac{n}{8^i}=1$ ? (Worried)