Posts

Showing posts from 2011

Finding the subtree with maximum imbalance.

This was given in the written test for Goldman Sach and I have solved this question in O(n) time complexity, as per my knowledge. If  any one could do better or would require my code. Contact me at pushpita1988@gmail.com  . I cannot attach the c code here.

Nicholas Sparks...whose words I admire :)

"“And when her lips met mine, I knew that I could live to be a hundred and visit every country in the world, but nothing would ever compare to that single moment when I first kissed the girl of my dreams and knew that my love would last forever.” Words and wonders all together, love could be defined with none tethered.

UGLY NUMBERS

Even numbers could be ugly!!!! I suddenly find number systems and C to be greatly interesting :) :) Recently going through the net I found a question... Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... shows the first 11 ugly numbers. By convention, 1 is included. We need to find 1500'th ugly number. ---------------------------------------------Best solution according to me--------------------------------------------------  if x is ugly, then so are 2x, 3x and 5x. So we can use a min-heap. Start with 1 in the heap. Now if we do the following in a loop: x = Heap.PopCurrentMin(); Heap.Insert(2x); Heap.Insert(3x); Heap.Insert(5x) I believe this will work. Not sure what the time complexity will be, but my guess is that this is reasonably efficient. :) If any one finds a better solution....Please do post!!!!

How to install leach protocol on ns2.34 in ubuntu 9.10

I suppose that ns-2.34 is installed with the compiler gcc-4.3. The home directory of ns-2.34 is "/opt/ns-allinone-2.34" 1- download the package "ns-234-leach.tar.gz" into the directory "/opt/ns-allinone-2.34/ns-2.34". https://docs.google.com/uc?id=0BzLWx...CNWG1NQK&hl=en 2- download the bash file "leach-setup.sh" into the directory "/opt/ns-allinone-2.34/ns-2.34". https://docs.google.com/uc?id=0BzLWx...CJSU5ZYG&hl=en 3- If the home directory of your "ns-2.34" is other than "/opt/...", then you need to find "/opt/ns-allinone-2.34" and replace with "yourpath/ns-allinone-2.34" for the file "leach-setup.sh". 4- move to the directory "/opt/ns-allinone-2.34/ns-2.34" and patch the file "leach-setup.sh" wsn@ubuntu:~$ cd /opt/ns-allinone-2.34/ns-2.34/ wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34$ bash leach-setup.sh 5- If the home directory of your "ns-2.34&