Documente Academic
Documente Profesional
Documente Cultură
For all the answers verification is required. Please comment/answer if you find
anything wrong.
====================================================
=====
int main()
{
int i=32242,j=find(i);
}
int find(int j)
{
if(j)
{
j = j%10 + find(j/10);
printf(" %d ",j);
}
return j;
}
[The question was almost like above, don't remember the exact value of i but it was
something less than 32667.]
Ans : This is a same old boring recursive function. Output can be found by
running code actually on PC.
====================================================
=====
====================================================
=====
(3) Given an 2D array A[M][N], we are converting it into A[N][M] along with rotating
it anti clockwise. What should be the mapping,
A[i][j] = A[?][?] (i,j are 0 based indices) (4 marks)
example:
.............................................4......8
1...2...3...4..............................3......7
.......................======>..........2......6
5...6...7...8..............................1......5
====================================================
=====
(4) Assume two sorted singly link lists. Merge them into a one sorted singly link list.
struct Node{
int data;
Node* next
};
Implement,
Node* SortedList(Node* list1, Node* list2); ( 6 marks )
while(1)
{
if(T1->next->data < T2->data)
{
Tmp = T2;
T2 = T2->next;
Tmp->next = T1->next;
T1->next = Tmp;
}
T1 = T1->next;
(5) Write test case(s) and explanation the same for above program. (6 marks)