Number of digits in a computation involving integers with different number of digits

62 Views Asked by At

Compute $\max(A+B, C+D) + E$ where $A,C$ have $n$ digits, $B,D$ have $3n$ digits, $E$ has $2n$ digits

What will be the primitive operations? What will be the output digit?

Hi for the above question I am not quite able to understand the primitive operation part. On re evaluation what I think is that $A+B$ would take $3n$ operations, $C+D$ would take $3n$ operations. Max would take $1$ operation. and then we add $E$ which is $2n$ also there is chance of carry over which makes it $3n + 3n + 2n + 1 + 1 = 8n + 2$ and there is nowhere I am able to get to the answer $9n + 1$ (which is the correct answer)

Further for the second part, what I think is that since both $A+B$ and $C+D$ produce $3n$ digit number, the max of it would be $3n$ digit number and adding $3n + 2n$ would result in a carry of $1$ so output digit is $3n + 1$. Correct me if I am wrong.