Microsoft Interview Question for Software Engineer / Developers






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

I am not good in C++ STL concepts , so I am wring code in C .

#define MAX_CHILD_NODES 10

typedef struct node{
      int val;
      struct node *child[MAX_CHILD_NODES];
}tNode;

void LeveTraversal(tNode *root)
{
  if( root == NULL )
  {
      return ;
  }
  else
  {
     tNode *p = NULL ;
     QueueADD(root);
     
     while( !QueueEmpty() )
     {
          p = QueueDelete();
          printf(" %d  ", p->val );
          for( int i = 0 ; i<MAX_CHILD_NODES ; i++ )
          {
               if( p->child[i] == NULL )
               {
                    break;
               }
               else
               {
                    QueueAdd( p->child[i] );
               } 
          } 
     }
  }
}

- siva.sai.2020 December 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

If you find any bug in my code, please let me know

- siva.sai.2020 December 09, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

You need not to break when a NULL child is encountered.
For some 0<=k<m<MAX_CHILD_NODES, if p->child[k] is NULL then it doesnt mean p->child[m] is also NULL.

- Tulley December 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Tulley, thanks

- siva.sai.2020 December 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

what is QueueAdd,QueueEmpty functions in the code? Always better if you can explain the code a bit more like an algorithim becasue people like me dont really understand code right away..

- Anonymous January 03, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

OK got it now after googling for algorithms of Level order tranversal that you need to make use of a queue to traverse this kind of a tree. Thanks for the code.

- Anonymous January 03, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

good

- badboy December 14, 2010 | Flag Reply


Add a Comment
Name:

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

Books

is a comprehensive book on 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