You are given a linked list and you are supposed to take it as input and return
Software QA/Tests Interview Questions from Microsoft
(Continued from previous question...)
You are given a linked list and you are supposed to take it as input and return
Question:
you are given a linked list and you are supposed to take it as input and return its node values as an integer ---
for example
if linked list it 2-<3-<4-<5-<NULL
it should return 2345 integer use functions definition as ---
int myconvert(Node *);
and structure for Node is
struct Node{
int data;
struct Node *root;
};
2) now you are given num1: 2-<3-<4-<NULL;
and num2: 3-<4-<NULL;
you should take two linked list as input and return a list like 2-<6-<8-<NULL; sum of corresponding elements and return a list
Node * newlist(Node *num1,Node *num2);
3) Write test cases to test 2nd program completely...
maybe an answer:
static int productListImp(List *p, int *val);
int productList(List *p)
{
int val = 0;
if(p == NULL)
return -1;
return productListImp(p, &val);
}
static int productListImp(List *p, int *val)
{
int product;
if(p->next == NULL)
return p->data;
product = productListImp(p->next);
(*val)++;
product = (p->data) * (pow(10, *val) + product;
return product
}
(Continued on next question...)
Other Interview Questions
|