Thursday, March 31, 2005

I read this interesting problem in Sahni, the problem is to generate all given subsets of a set. Sahni's answer is given on the web site at solution to exercise 5. I tried to solve the problem using iteration. There are two ways to do it

Convert Sahni's solution to use iteration

Use the method I describe (its a bit complex, but interesting)

The solution described in (1) eventually ends up generating all possible binary numbers for a word of length n. Where n is the number of elements in the set. This method will definitely not work for multisets. I solved the problem by first coming up with a method to generate combinations of C(n, k) which prints out all combinations of n taken k at a time. I have the C# implementation of the code, if you want to see it, let me know. This method can be easily extended to handle multisets (I think!)

Here is my implementation

//// I am not an expert C# programmer, // I am learning the language please // feel free to comment on the style // and/or on the code//using System;

PhysOrg.com is reporting this story on a cell phone with a built in projector. The image is taken from there. This sounds like fun, I can't wait to get hold of a device like that. The article is published here

Friday, March 25, 2005

Adobe have released GNU/Linux version of Acrobat Reader 7.0.Please grab from:ftp://ftp.adobe.com/pub/adobe/reader/unix/7x/7.0/enu/

The screenshot above is Adobe Reader 7 running on my computer. This reader seems much better than Adobe Reader 5. As you can see I am reading chapter 2 of the Linux Device Drivers 3rd Edition PDF book available for free online.

I spent quite a bit of time investigating permutations. The easiest known method for generating permutations is recursion. Iterative permutations are hard but not impossible. A quick comparison showed the following results. The C/C++ code without profiling was about 4-7 times faster than the java implementation.

The profiling had an impact on the C/C++ code. Java did better with profiling.

The recursive and the non-recursive versions did almost equally well. Here are some results for lengths 10 and 12.

rpermute is the recursive version of the permutation generator and permute is the lexicographic permutation generator. As can be seen, the execution times are almost the same. As far as the stack size is concerned, the iterative version uses a stack size of "s" and the recursive version goes upto a worst case of "ns".

The development of rpermute is much easier compared to the iterative version

Friday, March 18, 2005

In today's match, Steve Bucknor cost India dearly. The batsmen (Tendulkar) kept complaining about the bad light. In the end Bucknor gave him out when he was not, the fielding team themselves were not appealing as much. Please see Bucknor is useless. I wonder if ICC will ever take any action against such bad umpires, who are biased. He has made so many bad decisions and mostly against India. Do a google search and you will find out what many people think about him.

The only number that cannot be represented in signed integers of length k is 2k. The number -2k can be easily represented. What if n = -2k

Taking two's complement (add one to ones' complement of the number) of returns the same value. If you are interested in the reason for difference in the apostrophe placement for the ones' complement and two's complement - see Art of Computer Programming volume 2

Coming back to "n = -n", this code does not work for n = -2k.The same thing has been mentioned in Andrew Koenig's C Traps and Pitfalls

Wednesday, March 16, 2005

Even though his 35th century is evading him, he did join the 10,000 club. His performance has gone almost unnoticed, due to Sehwag's performance. The photo of him after getting there and a link to the story of his achievement. The story points to the location where the photo resides

I hope the Indian selector's will be patient with V V S Laxman. He is a great player and is one innings away from his display of class.

Tuesday, March 15, 2005

I was scared that this might not happen, but it has as it did the last time. The book is available as PDF (as of now) online. Please see Linux Device Drivers, Third Edition for more details and the PDF files.

Saturday, March 12, 2005

Please see the following email from Chris Wright. The new team talks about security disclosure, disclosure dates. This makes sense for enterprise installations and for security of Linux. The average geeky Linux programmer might complain, but I am glad to see the good things being adopted by the Linux maintainers.

Sometimes while solving a problem, I have discovered for myself that the discovery works two ways

If a small problem is solved, one can generalize the solution and it becomes a learning

If a generic problem is solved, one can apply it to niche areas and problems to solve complex problems

Usually, I keep oscillating between (1) and (2). However, I wonder whether one should apply (1) or (2) to a problem first? I suspect it should be (1) and the authors of Concrete Mathematics seem to agree. What do you think?

I think it is normal for everyone to expect a person good in one field to be generally good in others and that might be true. But I have come across people who are narrowly focused in their domain, that they might not be good at anything else. Technology is growing at such a rapid phase that it is not possible to keep up and be good at everything. So here's a suggestion