Amazon Interview Question Software Engineer / Developers




Comment hidden because of low score. Click to expand.
0
of 0 vote

Yes... Thanks

- Abhishek on February 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

geeksforgeeks.org/?p=646

- Gautham on February 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int max(int a,int b)
{
if(a>b)
return a;
else return b;
}
int TREE(node *t) //node is the node of the tree contains data left pointer and right pointer
{
if (t==NULL)
return 0;
else return ( 1+ max( TREE left[t], TREE right[t]))
}

- gautam on February 05, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

struct tree
{
   int data;
   struct tree *left;
   struct tree *right;
};

int depth = 0;
Depth(struct node *Root)
{
   int Level;
  
   if(Root == NULL) return;  
 
   Depth(Root->left,Level + 1);
   Depth(Root->right,Level + 1);

   if(depth < Level)
   {
      depth = Level;
   }
}

main()
{
   struct tree *Root;
   
   .........
   ........
   Some code for tree creation
   .........
   .........

   Depth(Root,0);

   printf("\n Depth of the tree is %d",depth);
}

- Abhishek on February 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

/*You meant */

Depth(struct tree *Root, int Level)
{
   //and remove this following declaration of level
   // int Level;

   Now your code.....

}

- Tanvi on February 03, 2010 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

depth ( root )
{
if ( root == Null)
System.out.println(" the depth is -1");
else
return ( 1 + max ( depth(left) , depth(right))
}

- watever on March 17, 2010 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book walking you through getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

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.

Learn More

Resume Review

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.

Learn More

Mock Interviews

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.

Learn More