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
Answer: Option B
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
Answer: Option A
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: Option A
Q8. Find the output of the following program
#include <stdio.h>
int main(){
int *ptr, a = 5;
ptr = &a;
*ptr =*ptr - 3;
printf("%d,%d", *ptr, a);
return 0;
}
Answer: 2,2
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-3x²-5
Answer: 1.0312
Q10. What will be the output?
#include <stdio.h>
int main(void){
int a[] = {10, 12, 6, 7, 2};
int i, *p:p=a+4;
for(i=0; i<5; i++)
printf("%d", p[-1]);
return 0;
}
a. 10 12 6 7 2
b. 10 12 6 7
c. 2 7 6 12
d. 2 7 6 12 10
Answer: Option D.
TELEGRAM FOR NOTIFICATION | Click Here |
Follow on Google News (in one click) | Click Here |
Disclaimer: These answers are provided only for the purpose of helping students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.
Also Available:
Problem Solving Through Programming In C NPTEL Assignment Answers Week 9