Usually in this case one could use an array / vector, possibly a little-endian (first low word). If you perform operations on the spot, use a constant coefficient when growing the array, then the amortized complexity for the redistribution remains O (1).
All operations must be performed at O (n) runtime, where n is the size of the input. EDIT : No, of course, more is needed for multiplication and separation, this answer says that it is at least O (N log N).
Just out of curiosity: Why are you redefining the wheel? Find a Java implementation here . C # also has .NET 4.0. Although it can be a good exercise to implement it myself (I remember how I did it once), if you just need functionality, then this is already in many computing environments.
source share