This is a subject on which I never thought I would be writing something before just now. Anyways here I am.
Obviously love is something on which greatest of poets, writers, philosophers have written.
Wait a minute just when I wrote my last line I just thought may be I can read other people's point of view before I write mine (although definitely it should not affect my thoughts). I was surprised to see this article
http://en.wikipedia.org/wiki/Love#Chemical_basis
Honestly I had never thought there can be a chemical explanation for love but here it is. Specially there are these few lines from the above article.
Recent studies in neuroscience have indicated that as people fall in love, the brain consistently releases a certain set of chemicals, including pheromones, dopamine, norepinephrine, and serotonin, which act in a manner similar to amphetamines, stimulating the brain's pleasure center and leading to side effects such as increased heart rate, loss of appetite and sleep, and an intense feeling of excitement. Research has indicated that this stage generally lasts from one and a half to three years.
These lines have made me believe that there will be time when Science will be able to explain almost everything. Scientists may give a theory atleast for each thing in the world which would people accept and would be too difficult to prove wrong. A lot of people believe Big bang theory.
Seems like I am diverting from topic :P. But I am really out of words after reading this article may be sometime later I shall write my views :)
--
Ashish Meena
Wednesday, September 30, 2009
Monday, September 28, 2009
Default value of fields and local variables in java
Default value of Fields :--
When we are declare field they get a default value even if we don't assign it, we can check them with a small example
public class DefaultValueTester {
int i;
double d;
short s;
long l;
char c;
boolean b;
Object o;
public static void main(String[] args) {
DefaultValueTester t = new DefaultValueTester();
System.out.println(t.i);
System.out.println(t.d);
System.out.println(t.s);
System.out.println(t.l);
System.out.println(t.c);
System.out.println(t.b);
System.out.println(t.o);
}
}
The out put of this program will be
0
0.0
0
0
false
null
But if we work with local variables things are going to be a bit different.
Lets now try
public static void main(String[] args) {
int i ;
System.out.println(i);
}
It fails to compile, so we can clearly see that no default value gets assigned to local variables
When we are declare field they get a default value even if we don't assign it, we can check them with a small example
public class DefaultValueTester {
int i;
double d;
short s;
long l;
char c;
boolean b;
Object o;
public static void main(String[] args) {
DefaultValueTester t = new DefaultValueTester();
System.out.println(t.i);
System.out.println(t.d);
System.out.println(t.s);
System.out.println(t.l);
System.out.println(t.c);
System.out.println(t.b);
System.out.println(t.o);
}
}
The out put of this program will be
0
0.0
0
0
false
null
But if we work with local variables things are going to be a bit different.
Lets now try
public static void main(String[] args) {
int i ;
System.out.println(i);
}
It fails to compile, so we can clearly see that no default value gets assigned to local variables
Saturday, September 26, 2009
Can we create a new Earth?
Today I watched Start trek. I generally like fiction and this was one of the movies I really enjoyed. Movie is about planet wars. Where planets convert to debris in seconds.
After watching movie a thought came to my mind. Well actually a series of thoughts came to my mind lets go through a few of them one by one. Its a very old question, does life exist outside earth somewhere in universe?
Many scientists have simply denied the possibility of life anywhere other. Some have claimed that series of events which make life possible are so rare that its just not possible. My question is all of us believe that universe is so big that we can possibly never know what is inside it. The light which reaches to us from stars, can we ever possibly go closer to even one of them and see what they really look like? When such thing like existence of life can happen on a planet near SUN, why cant such a phenomenon happen in billions of billions of other SUNS/ Stars. Besides that may be that there are things on some planet which support different kind of life. May be life without OXYGEN,WATER. I don't think we can just deny that life is just not possible out of earth , yes this might be true that we never come to know about it. In fact some things tells me we are not alone in this universe, there are people who are superior to us and there are people who are inferior to us. Its just a matter of time when someday someone will contact earth. I dont believe we are going to approach any planet with life though :)
Now here comes my main question, we have seen in some movies species moving to some new planet when there planet is going to destroy itself. Not now, may be after millions years there might be a time when age of earth gets over. It might just crash like an artificial satellite of NASA/ISRO crashes from orbit. Then what are our predecessors going to do? Should we move to another planet ? Can we ever find a planet which is exactly like earth, well if that is true than probably there are people thinking about us as we do for them. But lets say we can't find a planet like that. Can we create one ?
Can we create an earth?
Theoretically I would say we can, what we need for life is oxygen, water. Water we can make by chemical reactions if we have enough other chemicals on planet. Then we need oxygen/air, is there someway we can create a protection layer surrounding the planer which makes sure that no air passes through that layer then transfer air from earth to that planet. Once air is there it will never eave and it will be just like earth. We can experiment over this thing on smaller scale.
Well this is not gonna be easy but seems possible to me. May be someday technology really reaches such level when we can create our own new earth.
Regards,
Ashish Meena
After watching movie a thought came to my mind. Well actually a series of thoughts came to my mind lets go through a few of them one by one. Its a very old question, does life exist outside earth somewhere in universe?
Many scientists have simply denied the possibility of life anywhere other. Some have claimed that series of events which make life possible are so rare that its just not possible. My question is all of us believe that universe is so big that we can possibly never know what is inside it. The light which reaches to us from stars, can we ever possibly go closer to even one of them and see what they really look like? When such thing like existence of life can happen on a planet near SUN, why cant such a phenomenon happen in billions of billions of other SUNS/ Stars. Besides that may be that there are things on some planet which support different kind of life. May be life without OXYGEN,WATER. I don't think we can just deny that life is just not possible out of earth , yes this might be true that we never come to know about it. In fact some things tells me we are not alone in this universe, there are people who are superior to us and there are people who are inferior to us. Its just a matter of time when someday someone will contact earth. I dont believe we are going to approach any planet with life though :)
Now here comes my main question, we have seen in some movies species moving to some new planet when there planet is going to destroy itself. Not now, may be after millions years there might be a time when age of earth gets over. It might just crash like an artificial satellite of NASA/ISRO crashes from orbit. Then what are our predecessors going to do? Should we move to another planet ? Can we ever find a planet which is exactly like earth, well if that is true than probably there are people thinking about us as we do for them. But lets say we can't find a planet like that. Can we create one ?
Can we create an earth?
Theoretically I would say we can, what we need for life is oxygen, water. Water we can make by chemical reactions if we have enough other chemicals on planet. Then we need oxygen/air, is there someway we can create a protection layer surrounding the planer which makes sure that no air passes through that layer then transfer air from earth to that planet. Once air is there it will never eave and it will be just like earth. We can experiment over this thing on smaller scale.
Well this is not gonna be easy but seems possible to me. May be someday technology really reaches such level when we can create our own new earth.
Regards,
Ashish Meena
Monday, September 21, 2009
Does life really have to suck ?
These days I feel many times where am I headed? What are my goals? What are my ambitions? Is there something I desire in life? Where do I see myself in 10 years? Its like I get millions of questions.
I am 23 now, and if I think in a way I have not done really bad so far. I thank god that he provided me with opportunities which helped me get today where I am standing, but what now? Is it like from now onwards I shall have to take my own decisions? Or I am still going to leave to fate and destiny to choose a path for me and I will just continue moving on it. I remember a quote from TV series HEROES "choose a path or destiny with do that for you. Well destiny might choose the best path as well or at least I can make myself believe that it is the best path as I never would have been to any other path but is it worth it? Can we just let destiny decide our whole life? Well we can if we have faith in God and we can choose a path ourselves if we have faith in self. Do I have faith in self? Do I have faith in God? Well answers to both the questions is both yes and no. I do have faith in God for I have always achieved things for which I have worked hard, thanks a lot God. Please continue your mercy on me like this. But wait I said things for which I worked hard. I never got things for which I didnt work hard, so does it mean that I can be confident on myself? After all, its you who does things for you isnt it ? God doesn't write exams for you, he doesnt appear to interviews in your place.Well but luck is something worth considering always sometimes I feel that a lot of things in life are determined by forces you have no control over. Luck plays a major role and we can say that luck is decided by GOD. So its ultimately God. Well if we keep thinking like this its never going to end.
Well there is one Sanskrit Shloka which
कर्मण्येवाधिकारास्ते म फलेषु कदाचन |
मा कर्मफलहेतुर्भु मा ते संगोस्त्वकर्मणि॥
Karmanye vadhikaraste ma phaleshu kadachna
ma Karmaphalheturbhu ma te sangostvakarmani.
Ch. 2, 47
In English translation:
You have a right to perform your prescribed duty, but you are not entitled to the fruits of action। Never consider yourself the cause of the results of your activities, and never be attached to not doing your duty.
I believe this thing. I know that this is the best way to achieve happiness and success in life. I will try my best to follow this principle thought by great Krishna. Dear god give me strength.
----
Ashish
Thursday Oct 1 00:00:01 IST 2009
I am 23 now, and if I think in a way I have not done really bad so far. I thank god that he provided me with opportunities which helped me get today where I am standing, but what now? Is it like from now onwards I shall have to take my own decisions? Or I am still going to leave to fate and destiny to choose a path for me and I will just continue moving on it. I remember a quote from TV series HEROES "choose a path or destiny with do that for you. Well destiny might choose the best path as well or at least I can make myself believe that it is the best path as I never would have been to any other path but is it worth it? Can we just let destiny decide our whole life? Well we can if we have faith in God and we can choose a path ourselves if we have faith in self. Do I have faith in self? Do I have faith in God? Well answers to both the questions is both yes and no. I do have faith in God for I have always achieved things for which I have worked hard, thanks a lot God. Please continue your mercy on me like this. But wait I said things for which I worked hard. I never got things for which I didnt work hard, so does it mean that I can be confident on myself? After all, its you who does things for you isnt it ? God doesn't write exams for you, he doesnt appear to interviews in your place.Well but luck is something worth considering always sometimes I feel that a lot of things in life are determined by forces you have no control over. Luck plays a major role and we can say that luck is decided by GOD. So its ultimately God. Well if we keep thinking like this its never going to end.
Well there is one Sanskrit Shloka which
कर्मण्येवाधिकारास्ते म फलेषु कदाचन |
मा कर्मफलहेतुर्भु मा ते संगोस्त्वकर्मणि॥
Karmanye vadhikaraste ma phaleshu kadachna
ma Karmaphalheturbhu ma te sangostvakarmani.
Ch. 2, 47
In English translation:
You have a right to perform your prescribed duty, but you are not entitled to the fruits of action। Never consider yourself the cause of the results of your activities, and never be attached to not doing your duty.
I believe this thing. I know that this is the best way to achieve happiness and success in life. I will try my best to follow this principle thought by great Krishna. Dear god give me strength.
----
Ashish
Thursday Oct 1 00:00:01 IST 2009
some great songs
There are some songs which I have listened people playing and liked but never played myself. A few of them I managed to listen today :)
Here is a great song from Pink Floyd
Here is one more song which is one of my favorite but managed to listen it myself recently only
Really great songs :)
Here is a great song from Pink Floyd
Here is one more song which is one of my favorite but managed to listen it myself recently only
Really great songs :)
Sunday, September 13, 2009
Some Interview questions
Hi,
I was going through a site and found a few interview questions. I believe they are worth sharing. I will be putting answers to them as well.
1. Given a Binary Search Tree, write a program to print the kth smallest element ? Now can you do it without using any static/global variable. You can't pass the value k to any function also.
2. Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.
3. Given a string,find the first un-repeated character in it? Give some test cases
4. You are given a dictionary of all valid words. You have the following 3 operations permitted on a word: delete a character, insert a character, replace a character. Now given two words - word1 and word2 - find the minimum number of steps required to convert word1 to word2. (one operation counts as 1 step.)
5. What is the time and space complexities of merge sort and when is it preferred over quick sort?
6. Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
7. Given an array of size n, containing every element from 1 to n+1, except one. Find the missing element.
8. You have 50,000 html files, some of which contain phone numbers. How would you create a list of all the files which contain phone numbers?
9. Given two sets, Write a function to provide the union of them.
10. Design an algorithm to calculate the most user viewed pages
11. Design an algorithm to find duplicates in an array.
12. Design an algorithm and write code to serialize a binary tree.
13. Design an algorithm and write code to find two numbers in an array whose sum equals a given value
14. Given two binary trees, find whether or not they are similar.
15. Assume your computer is reading characters one by one from a stream (you don't know the length of the stream before ending). Note that you have only one character of storage space (so you cann't save the characters you've read to a something like a strong). When you've finished reading you should return a character out of the stream with equal probability.
16. You are provided with a stream of numbers, design a data structure to store the numbers in the stream along with their no. of occurrences.
17. Given two sorted arrays A1 and A2, of lengths L1 and L2 , L1 < L2 and the last L1 slots in A2 are vacant, get me all the numbers in A2, sorted in the most efficient manner without using extra space. This was a written test question in which I blabbered quick sort will do..
18. In a array of size n , there is one number missing and one number repeated twice. Find them.
I was going through a site and found a few interview questions. I believe they are worth sharing. I will be putting answers to them as well.
1. Given a Binary Search Tree, write a program to print the kth smallest element ? Now can you do it without using any static/global variable. You can't pass the value k to any function also.
2. Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.
3. Given a string,find the first un-repeated character in it? Give some test cases
4. You are given a dictionary of all valid words. You have the following 3 operations permitted on a word: delete a character, insert a character, replace a character. Now given two words - word1 and word2 - find the minimum number of steps required to convert word1 to word2. (one operation counts as 1 step.)
5. What is the time and space complexities of merge sort and when is it preferred over quick sort?
6. Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
7. Given an array of size n, containing every element from 1 to n+1, except one. Find the missing element.
8. You have 50,000 html files, some of which contain phone numbers. How would you create a list of all the files which contain phone numbers?
9. Given two sets, Write a function to provide the union of them.
10. Design an algorithm to calculate the most user viewed pages
11. Design an algorithm to find duplicates in an array.
12. Design an algorithm and write code to serialize a binary tree.
13. Design an algorithm and write code to find two numbers in an array whose sum equals a given value
14. Given two binary trees, find whether or not they are similar.
15. Assume your computer is reading characters one by one from a stream (you don't know the length of the stream before ending). Note that you have only one character of storage space (so you cann't save the characters you've read to a something like a strong). When you've finished reading you should return a character out of the stream with equal probability.
16. You are provided with a stream of numbers, design a data structure to store the numbers in the stream along with their no. of occurrences.
17. Given two sorted arrays A1 and A2, of lengths L1 and L2 , L1 < L2 and the last L1 slots in A2 are vacant, get me all the numbers in A2, sorted in the most efficient manner without using extra space. This was a written test question in which I blabbered quick sort will do..
18. In a array of size n , there is one number missing and one number repeated twice. Find them.
Thursday, September 10, 2009
I am 23 ....
I turned 23 now. Well when someone turns 18 he says "yippe, I am 18." Similar thing happens on 21. In a ways we can say that each birth day deserves celebration until you reach 21.
But after 21, its like counting gets reversed. Each new birthday you feel "damn it, one more year of my life is over".
All we can do is just wish and resolve that we shall try our best not to waste the next year we have ahead.
Thu Sep 10 23:57:51 IST 2009
But after 21, its like counting gets reversed. Each new birthday you feel "damn it, one more year of my life is over".
All we can do is just wish and resolve that we shall try our best not to waste the next year we have ahead.
Thu Sep 10 23:57:51 IST 2009
Sunday, September 06, 2009
Want to trace a caller ?
Many a times we receive calls from unknown number and we might want to figure out where is the person calling from. Well we can't determine the exact spot but definitely we can narrow down to a city. All we need is the first four digits of the number and we can determine the operator and circle of the caller.
We can use these links to figure this out.
http://coai.in/msccodes.php
http://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India
So next time you receive a call and you have access to the net make sure to use this :)
--
Ashish Meena
We can use these links to figure this out.
http://coai.in/msccodes.php
http://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India
So next time you receive a call and you have access to the net make sure to use this :)
--
Ashish Meena
Subscribe to:
Posts (Atom)