Algorithms, Theory, Spirituality, Life, Technology, Food and Workout : trying to sort these deterministically in $\Theta(1)$ time (constant time).
Tuesday, March 09, 2010
[LIFE] Keeping the PACE of productivity is very hard.
Monday, February 01, 2010
[TECH] An efficient External sorting API
Sorting is one of the most fundamental operation on data. Very efficient algorithms exists to perform this operation. Most of the programming languages are shipped with some sorting API with them. Most of them are in-memory sorting algorithms. However I find all these APIs are so bloated which are unfortunately by produces of abusing and overusing the object oriented concepts. On the other hand the bloated code may run fine as long as the input size is bounded by some constant -- which is most of the case for many applications. Any way I guess I'm getting into a little off-topic but if you are interested see the flames between C++ and C hackers on the Linux kernel mailing list here
On the other hand most of these programming APIs lack a solid External sorting algorithms. External sorting is * THE MOST * fundamental operation especially when you want to build algorithm on monster and massive datasets. You can try my new -- well old but wrapped in a new API, External sort please get it here . I'll try to post some examples how to use if when I get more time.
Saturday, January 30, 2010
Rounding An Integer To The Next Maximal Mutliple Of A Given Radix Power
So coming back to our original problem given the modulo- representation
, we would
like to round
to
, where
is the smallest multiple of
such that
.
To accomplish this task we need to examine the first (from right)
digits in the modulo-
representation of
. In fact the value of in those
bits is the reminder we get when we
divide
by
, so if
is the value in those
bits then
. When
we can elegantly use the bit-wise operators to accomplish this. So if some one gives
an integer
and ask to find a smallest
which is a multiple of
then we
use the following C-statement to accomplish this
.
Where
are the standard bit-wise operators in C.