-
175.
-
176.
-
177.
-
178.
Statement for Linked Answer Question ::
Consider the following C program that attempts to locate an element x in an array Y[ ] using binary search. The program is erroneous.
1. f(int Y[10], int x) {
2. int i, j, k;
3. i = 0; j = 9;
4. do {
5. k = ( i + j)/2;
6. if (Y[K] < x) i = k; else j = k;
7. } while ((Y[K] != x) && (i < j));
8. if(Y[K] == x) printf(“x is in the array”);
9. else printf(“x is not in the array”);
10. }
[1] On which of the following contents of Y and X does the program fail? [2 marks]
(A) Y is [ 1 2 3 4 5 6 7 8 9 10] and x < 10
(B) Y is [ 1 3 5 7 9 11 13 15 17 19] and x < 1
(C) Y is [ 2 2 2 2 2 2 2 2 2 2 ] and x > 2
(D) Y is [ 2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even[2] The correction needed in the program to make it work properly is [2 marks]
(A) change line 6 to : if (Y[K])<X)i=K+1;else j=K-1;
(B) change line 6 to :if(Y[K])<X)i=K-1;else j=K+1;
(C) change line 6 to :if(Y[K])< = X)i=K;else j=K;
(D) change line 7 to :} while ((Y[k]==X)&&(i <j));asked in Computer Science And Engineering, 2008
View Comments [0 Reply]
-
179.
Statement for Linked Answer Questions::
Consider the following ER diagram:
[1] The minimum number of tables needed to represent M, N, P, R1, R2 is [2 marks]
(A) 2
(B) 3
(C) 4
(D) 5[2] Which of the following is a correct attribute set for one of the tables for the correct answer to the above question? [2 marks]
(A) {M1, M2, M3, P1}
(B) {M1, P1, N1, N2}
(C) {M1, P1, N1}
(D) {M1, P1}last reply by CpjJwWHV • 13 years ago • asked in Computer Science And Engineering, 2008
View Comments [3 Reply]
-
180.
Statement for linked Answer Questions ::
Let xn denote the number of binary strings of length n that contain no consecutive 0s.[1] Which of the following recurrences does xn satisfy? [2 marks]
(A) xn = 2xn-1
(B) xn = x[n/2] + n
(C) xn = x[n/2] + 1
(D) xn = xn-1 + xn-2
[2] The value of x5 is [2 marks]
(A) 5
(B) 7
(C) 8
(D) 16asked in Computer Science And Engineering, 2008
View Comments [0 Reply]