Monday, December 14, 2009

Written Test Questions

Q1.

Given a program to find the intersection point of a two linked list. Try to find and correct the errors if any
.

node * find_intersection_point(node * list1,node * list2)
{
node * p1,*p2;
int l1,l2;
p1=list1;
p2=list2;
l1=LengthOf(p1);
l2=LengthOf(p2);
if(l1 < l2) { while(l1 < l2) { p1=p1->next;
}
}
else
{
while(l2 < l1) { p2=p2->next;
}
}
while(p1->next != p2->next)
{
p1=p1->next;
p2=p2->next;
}
return p1->next;
}

Q2.

Write a program to find the effective resistance between two points in a circuit.

For example,
A B 10 ohms
B C 5 ohms
B C 5 ohms
B C 5 ohms
C D 20 ohms
Find the effective resistance between A and D.
Print error if the effective resistance cannot be calculated.
The effective resistance is

R = R1 + R2 series

1/R = 1/R2 + 1/R2 parallel

Q3.

Given a function to find the reverse of the words in a sentence,
write testcases to find the correctness of the function.

If the input is "My name is Dinesh" the output will be "Dinesh is name My".

Q4.

Design a Universal Remote Control for Indian Market.