Given an integer n, write a function that returns count of trailing zeroes in n!. Examples: Input: n = 5 Output: 1 Factorial of 5 is 20 which has one trailing 0. Input: n = 20 Output: 4 Factorial of 20 is 2432902008176640000 which has 4 trailing zeroes. Input: n = 100 Output: 24
public void print_leaf_to_root(Node root){
ReplyDeleteQueueDemo qd = new QueueDemo();
Queue queue = qd.create_queue(); /* returns Queue*/
Stack s = new Stack();
qd.enqueue(queue, root);
s.push(root.value);
while(!qd.isempty(queue)){
Node root_1 = qd.dequeue(queue);
if(root_1.right!=null){
qd.enqueue(queue, root_1.right);
}
if(root_1.right!=null){
s.push(root_1.right.value);
}
if(root_1.left!=null){
qd.enqueue(queue, root_1.left);
}
if(root_1.left!=null){
s.push(root_1.left.value);
}
}
while(!s.isEmpty()){
System.out.println(s.pop());
}
}