For last few days, or rather weeks, my blog was really slow. Infact the site was throwing resource limit error at times. I contacted my webhosting provider, but they just replied they cannot find anything. So I decided to do some investigation on my own.
First step was to check memory and CPU usage, which turned out to be very high, almost 100%. The fishy thing I figured out was disk space usage, which was way above data I have, so I checked the file system. I figured out hundreds of core.XXXXX files. A little googling showed that these were dump files created by Apache for memory dump, in case some error / crash occured. Deleting these extra files did solve the issue.
More info on the topic
We know that future of online shopping is bright in countries like India. With sites like snapdeal, flipkart, amazon, shopclues, jabong, myntra etc, things will heat up further, which will be beneficial for end customer as he will get multiple options.
With Online shopping, people are also moving away from loyalty to one vendor or brand. Earlier we used to go for same shop for various electronics needs, but now before buying we can compare prices and offers on different websites (plus nearby stores). And with this knowledge, there are various player which are ready to help you with comparison among online sites. There are websites like Junglee, which will help you compare various prices, and I recently came across some browser extensions which will help you compare prices on the fly when you are viewing the product itself. Makkhichoose is one such extensions. Though it is not cooked up completely yet (I could see some products on various sites which were not reported correctly), but it definitely shows the where the future of online shopping heading to.
Here are top 10 web security threats highlighted by OWASP or Open Web Application Security Project
Problem statement- 3 divides 111 , 13 divides 111111 etc.. find a number having all one’s which is shortest divisible by a given number which has 3 as its last digit.
Logic- The challenge here is that you will soon run out of limit for int or long if you keep on increasing the number. So the idea is to divide in a way which you used to do on paper for large numbers
Start with 1 (or 11) and keep adding one, keep a count of 1s added, divide by the required number unless the reminder is 0.
public static void divide(int num)
I had discussed Breadth first and Depth First traversal algorithms sometime back.
There are 3 important traversing algorithms for tress. http://en.wikipedia.org/wiki/Tree_traversal
-Travel Left, Travel Root, Travel Right.
-Root, Left, Right
-Left, Right, Root
Here is recursive implemenation
public void inOrder(Node root)
public void preOrder(Node root)
public void postOrder(Node root)
Problem: You have two options
1: One successful shot at the hoop
2: 2 of 3 successful shots at the hoop
Let P be the probability of making a successful hit, for what value of P will you choose option 2 over 1.
If P is probability for option 1
Option 2, we can have 2 cases of success, one all 3 shots are successful – P*P*P
or 2 Hits and 1 Miss (HHM, HMH, MHH) 3 cases, each with probability of P*P*(1-P) i.e. 1-P for one miss. as there are 3 cases, total probability is 3*P*P*(1-p). Combining both result for option 2, P*P*P + 3*P*P*(1-P).
To prefer option 2,
P*P*P + 3*P*P*(1-P)>P
Can be solved to quadratic equation
P>1 not possible so
P>1/2 or .5
Choose option 2 when probability of hitting hoop is more than 0.5
Monty Hall problem is an interesting problem that plays with probability.
Problem: There are three doors, say A, B and C. Behind one of the doors there is a prize and two are empty. You have to make a choice and try to win the prize. You choose a door say A, now host opens the door C, which is empty. The question is, should you switch the doors?
Solution: According to one solution proposed, Switching doors will increase probability of winning. This is the explanation behind that
Initially all 3 doors has probability of 1/3 of winning. So when we choose door A, we had probability of winning – 1/3. Now Doors B & C have collective probability of winning as 2/3. So when we know C is empty, probability of prize behind B is 2/3(?).
Frankly the argument does not look very strong, for me the new probability should be 1/2 for each door.
Read more here- http://en.wikipedia.org/wiki/Monty_Hall_problem