You are on page 1of 3

THIAGARAJAR COLLEGE OF ENGINEERING, MADURAI 625 015.

Department of Electronics and Communication Engineering


Continuous Assessment Test – 2
Course Code 14EC320 Course Name Problem Solving using Computers
Degree B.E Programme ECE Semester III
Date 29/09/2015 Duration 90 minutes Max. Marks 50
Faculty-in-Charge Dr. S. Ponmalar

Assessment Pattern
Remember Understand Apply Analyze Evaluate Create Total
10 10 30 - - - 50

Answer All Questions


Part A (Remember) 5 x 2 =10
A1. CO 1
List the types of function calls.
A2. Define recursive function. CO 1
A3. Define pointer. CO 1
A4. Draw flowchart to find maximum element in a given set of numbers. CO 1
A5. Write down the algorithm to insert a number at the beginning of a list. CO 1

Part B (Understand) 2 x5 =10


Write the output of following code segments.
B1. main( ) CO 1
{
int i = 4, j = 2 ;
fun ( &i, j ) ;
printf ( "\n%d %d", i, j ) ;
}
fun ( int *i, int j )
{
*i = *i * *i ;
j=j*j;
}

B2. main( ) CO 1.
{
float a = 13.5 ;
float *b, *c ;
b = &a ; /* suppose address of a is 1006 */
c=b;
printf ( "\n%u %u %u", &a, b, c ) ;
printf ( "\n%f %f %f %f", a, *(&a), *b, *c ) ;
}
B3. main() CO 1
{

Page 1 of 3
int n[3][3]={2,4,6,8,10,1,3,5,7}
printf(“%u %u %u”, n, n[2], n[2][2] );
}
B4. main() CO 1
{
int arr[ ]={0,1,2,3,4};
int *ptr;
for(ptr=arr+4;ptr>=arr; ptr- -)
printf(“%d \n”, arr[ptr-arr]);
}
B5. main() CO 1
{
int a=3, b=2, c=1, d;
d=a|b&c;
printf(“d=%d\n”,d);
d=a&b|c;
printf(“d=%d\n”,d);
}

Part C (Apply) 3 x 10 =30


C1. Given an unsorted array of n elements, develop an algorithm to search for a CO 2
given number with log n time complexity. Implement the algorithm using
functions and pointers.

(OR)
C2. Develop an algorithm to find the sum of the digits of a given number and CO 2
implement it using recursive function.

C3. Develop an algorithm, draw flowchart and write a program to process a 4×4 CO 2
matrix as given below.
(i) Interchange column1 and column 4
(i) interchange row3 and row4
and print the resultant matrix.
(OR)
C4. Given two ordered sets A and B with n and m elements respectively, CO 2
develop an algorithm to find the intersection of two sets and implement it
using any high level language. For example, if we have
A[5] = {2, 5, 7, 8, 12};
B[6] = {1, 2, 5, 12, 15, 20};
then C[9] = {2, 5,12}.

C5. Write a function that computes and returns the dot product of two vectors. CO 5
The dot product of two vectors a = [a0, a1, … , an-1] and b = [b0, b1, … , bn-1] is

Page 2 of 3
n−1
a⋅b= ∑ ai bi =a0 b0 +a1 b 1 +¿⋅¿⋅+a n−1 bn−1
defined as: i=0
OR
C6. Assume we are given some terrain data represented by a two-dimensional CO 5
array A[5][5], where each cell of the array is an integer number denoting the
elevation at that position. Develop an algorithm to determine the peak
values and its position. Implement the algorithm for an N*N matrix.

Note: A cell A[i][j] is considered having peak value, if A[i][j] is greater than
all of its neighborhood cells. Note that boundary cells do not have 8
neighbors, so we will not consider them.

[ ]
1 5 9 2 9
4 1 7 10 3
A= 5 15 8 6 2
12 7 9 1 10
3 5 8 9 1
e.g
o/p: peak value:10 position: A[2][4]
peak value: 15 position: A[3][2]

Page 3 of 3

You might also like