satyajeettripathy
BAN USERThe easiest way is to check the maximum power of 5 which can be there in factorial.
10=5x2
If we are calculating the factorial then n!=n x n1 .... 1= A x 5^p x 2^q, hence it will depend on the value of p which will define the number of zeros.
Steps to find the max number of 5 is
If the number is say Z then max power of 5
p= z/(5) +z/(25) + z/(125)...z/(5^n) till z/(5^n) results a integer number.
If the braces are balanced, (going by the counter method by @ajeet) you will end up with sum 0.
Hence even you may divide the file into chunks, with help of some marker method or use a file system which gives you chunks of file and then put each chunk for counting the braces. Each parallel process will end up in a number. These numbers again should add up to 0.
Complexity O(n)
public List getListOfNodes(Node root,int k)
{
ArrayList<Node> list= new ArrayList<Node>()
getLeaves(root,list,k);
return list;
}
public int getLeaves(Node node,ListnNode[] nodeList,int k)
{
int numLeafL,numLeafR=0
if(node.getLeft==null && node.getRight==null)
{
return 1;
}
if(node.getLeft)
{
numleafL=getLeaves(node.getLeft);
}
if(node.getRight)
{
numleafR=getLeaves(node.getRight);
}
currentLeafcount=numLeafL+numRight;
if(currentLeafCount==k)
{
nodeList.add(node)
}
return currenLeafCount;
}

satyajeettripathy
January 22, 2014 Steps:
1. Each Object should implement Serializable
2. Let's create a key( from the number of doors and color ) so that the key is incremental and unique.
3. Assuming we have 11m doors and 11m color. Lets divide the objects and put into files of chunks say 1MB per file(this can be optimized if needed). Each file will be mapped to the key of the first object serialized into the file.
4. Use this keys to create a Binary Search tree and map the key to the file name in a hashmap.
5. Take input of the object search requirement. Create the key. Search in the BST. Find the file which might contain the serialized object. Load the file and do a normal search of the Exact object instance you might need.
The tuning factor might be the file chunk size.
How would you solve this in JAVA?
 satyajeettripathy March 27, 2013Open Chat in New Window
Suppose the tree has only one element,given the above logic,
 satyajeettripathy January 29, 2014a
sum+=root.info; ==> sum=a
root.info=sumroot.info;===> root.info=aa => root.info=0;
How to go about this problem?