How is schoolbook long division an O(n^2) algorithm?

Posted by eSKay on Stack Overflow See other posts from Stack Overflow or by eSKay
Published on 2010-03-21T06:11:52Z Indexed on 2010/03/21 6:21 UTC
Read the original article Hit count: 371

Filed under:
|
|
|

Premise:

This Wikipedia page suggests that the computational complexity of Schoolbook long division is O(n^2).

Deduction:

Instead of taking "Two n-digit numbers", if I take one n-digit number and one m-digit number, then the complexity would be O(n*m).

Contradiction:

Suppose you divide 100000000 (n digits) by 1000 (m digits), you get 100000, which takes six steps to arrive at.

Now, if you divide 100000000 (n digits) by 10000 (m digits), you get 10000 . Now this takes only five steps.

Conclusion:

So, it seems that the order of computation should be something like O(n/m).

Question:

Who is wrong, me or Wikipedia, and where?

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about big-o