Citrix Online Interview Question for Software Engineer / Developers






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

int printPath(NODE* root, int v)
   {
       if(root == NULL) return 0;
       if(root->v == v) 
       {
           printf("%d<-", root->v);
           return 1;
       }
       if( printPath(root->left,v) || printPath(root->right, v))
       {
            printf("%d<-", root->v);
            return 1;
       }
       else
       {
           return 0;
        }
    }

- chenming831 June 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice1!

- seeker7 June 28, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Cool!

- learner October 24, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Doesn't this print the nodes in the reverse order? i.e it starts printing from the required node to the root. We need the reverse of this. Correct me if I am wrong!

- Anju December 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

int search_path(node *root,int d)
{
if(!root) return 0;
if(root->data==d)
{
printf("%d",d);
return 1;
}
if(search_path(root->left))
{
printf("%d",root->left->data);
return 1;
}
if(search_path(root->right))
{
printf("%d",root->right->data);
return 1;
}
}

- irash February 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Do a BFS, maintain a map, before pushing the child of every node to queue, push the node and its parent to map. Once the node is found, use the map to find the parent and push the parent in stack till NULL parent is found, at that time pop out the elements of stack and print them

- Anonymous June 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Do a BFS, maintain a map, before pushing the child of every node to queue, push the node and its parent to map. Once the node is found, use the map to find the parent and push the parent in stack till NULL parent is found, at that time pop out the elements of stack and print them

- Dipkin June 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Dipkin: Nice method. Can be done iteratively and seems efficient too.

- CodeBoyS August 13, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Dipkin: Nice method. Can be done iteratively and seems efficient too.

- CodeBoyS August 13, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int search_path(node *root,int d)
{
if(!root) return 0;
if(root->data==d)
{
printf("%d",d);
return 1;
}
if(search_path(root->left))
{
printf("%d",root->left->data);
return 1;
}
if(search_path(root->right))
{
printf("%d",root->right->data);
return 1;
}
}

- irash February 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

the question is to print route sequentially, so the correct one would be;

print_route(node * N, int key)
{

- Kruthi PESIT October 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

the question is to print route sequentially, so the correct one would be;

print_route(node * N, int key)
{
if(N==null)
exit(0);
if(key< N->value)
{
insert(L,n->value);
N=N->lchild;
print_route(N,key);
}
else if(key>N-> value)
{
insert(L,n->value);
N=N->rchild;
print_route(N,key);

}
else if(key==N->value)
{ insert(L,n->value);
}
while (L!=null)
{
printf("%d",L->info)
L=L->next;
}
}

insert(list* L, int k)
{
node=(list*)malloc(sizeof(struct list));

if(L==null)
{ L=node;
}
else if(node->info<L->info)
{
node->next=L;
L=node;
}
else
{
list* first=L;
list*nxtptr;
while (node->info > first->info)
{
nxtptr=first;
first=first->next;
}
nxtptr->next=node;
node->next=first;
}
return L;
}

- Kruthi PESIT October 15, 2012 | 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