is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
public class BinaryTree {
- jaikuadwani October 07, 2012class Node
{
Node(int i)
{
data=i;
}
int data;
Node nodeLeft;
Node nodeRight;
}
static BinaryTree tree = new BinaryTree();
static Node createTree()
{
Node l1_1 = tree.new Node(30);
Node l2_1 = tree.new Node(25);
Node l2_2 = tree.new Node(35);
Node l3_1 = tree.new Node(20);
Node l3_2 = tree.new Node(28);
Node l3_3 = tree.new Node(32);
Node l3_4 = tree.new Node(50);
Node l4_1 = tree.new Node(10);
Node l4_2 = tree.new Node(22);
Node l4_3 = tree.new Node(27);
Node l4_4 = tree.new Node(29);
Node l4_5 = tree.new Node(31);
Node l4_6 = tree.new Node(34);
Node l4_7 = tree.new Node(38);
Node l4_8 = tree.new Node(55);
l1_1.nodeLeft=l2_1;
l1_1.nodeRight=l2_2;
l2_1.nodeLeft=l3_1;
l2_1.nodeRight=l3_2;
l2_2.nodeLeft=l3_3;
l2_2.nodeRight=l3_4;
l3_1.nodeLeft=l4_1;
l3_1.nodeRight=l4_2;
l3_2.nodeLeft=l4_3;
l3_2.nodeRight=l4_4;
l3_3.nodeLeft=l4_5;
l3_3.nodeRight=l4_6;
l3_4.nodeLeft=l4_7;
l3_4.nodeRight=l4_8;
return l1_1;
}
public static void main(String p[])
{
Node root= null;
root = tree.createTree();
System.out.println(sumOfLeaves(root));
}
static int sumOfLeaves(Node node)
{
int total = 0;
if(node.nodeLeft != null)
total += sumOfLeaves(node.nodeLeft);
else
{
if(node.nodeRight == null)
return node.data;
else
return 0;
}
//total += node.data;
if(node.nodeRight != null)
total += sumOfLeaves(node.nodeRight);
else
{
if(node.nodeLeft == null)
return sumOfLeaves(node.nodeRight);
else
return 0;
}
return total;
}
}