# Problem Solving Through Programming In C NPTEL Week 10 Solutions

This set of MCQ(multiple choice questions) focuses on the Problem Solving Through Programming In C NPTEL Week 10 Solutions.

NOTE: You can check your answer immediately by clicking show answer button. Problem Solving Through Programming In C NPTEL Week 10 assignment answers” contains 10 questions.

Now, start attempting the quiz.

### Problem Solving Through Programming In C NPTEL Week 10 assignment answers

Q1. What is the output of the C program given below?

a) n1 = 9, n2 = 10
b) n1 = 6, n2 = 11
c) n1 = 7, n2 = 12
d) n1 = 6, n2 = 10

Answer: b) n1 = 6, n2 = 11

Q2. Bisection method is used to find

a) Derivative of a function at a given point
b) Numerical integration of a function within a range
c) The root of a function
d) None of the above

Answer: c) The root of a function

Q3. In __________, the search starts at the beginning of the list and checks every element in the list.

a) Linear search
b) Binary search
c) Hash search
d) Binary tree search

Q4. What is the worst-case complexity of bubble sort?

a) O(N logN)
b) O(logN)
c) O(N)
d) O(N2)

Q5. What maximum number of comparisons can occur when a bubble sort is implemented? Assume there are n elements in the array.

a) (1/2)(n-1)
b) (1/2)n(n-1)
c) (1/4)n(n-1)
d) None of the above

Problem Solving Through Programming In C NPTEL Week 10 assignment answers

Q6. What are the correct intermediate steps of the following data set when it is being sorted with the bubble sort? 7, 4, 1, 8, 2

a) 4, 7, 1, 8, 2 â†’ 4, 1, 7, 2, 8 â†’ 4, 1, 2, 7, 8 â†’ 1, 4, 2, 7, 8 â†’ 1, 2, 4, 7, 8
b) 4, 7, 1, 8, 2 â†’ 4, 1, 7, 8, 2 â†’ 4, 1, 7, 2, 8 â†’ 1, 4, 7, 2, 8 â†’ 1, 4, 2, 7, 8 â†’ 1, 2, 4, 7, 8
c) 4, 7, 1, 8, 2 â†’ 1, 4, 7, 8, 2 â†’ 1, 4, 2, 7, 8 â†’ 1, 2, 4, 7, 8
d) 4, 7, 1, 8, 2 â†’ 4, 7, 1, 2, 8 â†’ 1, 4, 7, 2, 8 â†’ 1, 4, 2, 7, 8 â†’ 1, 2, 4, 7, 8

Q7. Which of the following statement is correct for the 2 arrays with respect to A and B.
int *x[5];
int *(y[5]);
A. Array of pointers
B. Pointer to an array

a) x is A, y is B
b) x is A, y is A
c) x is B, y is A
d) y is B, y is B

Answer: b) x is A, y is A

Problem Solving Through Programming In C NPTEL Week 10 assignment answers

Q8. Find the output of the following program

Problem Solving Through Programming In C NPTEL Week 10 assignment answers

Q9. What is the solution of the equation given below using the Bisection Method up to four decimal places? (Consider the root lying on positive quadrant only and compute the root till five iterations only)
f(x) = xe2x – 3x2 – 5

Q10. What will be the output?

a) 10 12 6 7 2
b) 10 12 6 7
c) 2 7 6 12
d) 2 7 6 12 10

Answer: d) 2 7 6 12 10

Problem Solving Through Programming In C NPTEL Week 10 assignment answers

### Previous Course – NPTEL Week 10 assignment answers

Q1. The bisection method is used to find

a) Derivative of a function at a given point
b) Numerical integration of a function within a range
c) The root of the function
d) None of the above

Answer: c) The root of the function

Q2. In __________ , the search starts at the beginning of the list and checks every element in the list.

a) Linear search
b) Binary search
c) Hash search
d) Binary tree search

Q3. What is the advantage of a recursive approach over an iterative approach?

a) Consumes less memory
b) Less code and easy to implement
c) Consumes more memory
d) More code has to be written

Answer: b) Less code and easy to implement

Q4. Which of the following is not an application of binary search?

a) To find the lower/upper bound in an ordered sequence
b) Union of intervals
c) Debugging
d) To search an unordered list

Answer: d) To search an unordered list

Q5. A function is given by y – e-y = 0. Find the root between [0, 1] by using Bisection method.

a) 0.655
b) 0.665
c) 0.565
d) 0.656

Problem Solving Through Programming In C NPTEL Week 10 solutions

Q6. What would be the equivalent pointer expression for referring to the array element a[i][j][k][l]?

a) (((*(a+i)+j)+k)+l)
b) *(*(*(*(a+i)+j)+k)+l)
c) (*(*(a+i)+j)+k+l)
d) *((a+i)+j+k+l)

Q7. What will be output when you execute the following C code?
#include<stdio.h>
int main()
{
short num[3][2] = {2,5,11,17,23,28};
printf(“%d, %d”, *(num+2)[0],**(num+1));
return 0;
}

a) 23, 11
b) 23, 23
c) 11, 17
d) 17, 17

Problem Solving Through Programming In C NPTEL Week 10 solutions

Q8. Assume sizeof an integer and a pointer is 4 bytes. What is the output?
#include<stdio.h>
#define A 5
#define B 8
#define C 2
int main()
{
int (*x)[A][B][C];
printf(“%d”, sizeof(*x));
return 0;
}

Problem Solving Through Programming In C NPTEL Week 10 solutions

Q9. Find the output of the following program
#include<stdio.h>
int main()
{
int *ptr, a = 12;
ptr = &a;
*ptr = *ptr – 2**ptr;
printf(“%d, %d”, *ptr, a);
return 0;
}

Q10. What is the solution of the equation given below using the Bisection Method up to four decimal places? (Consider the root lying on positive quadrant only and compute the root till five iterations only)
f(x) = xe2x – 3x2 – 5