Vous êtes sur la page 1sur 5

Question Paper

Total time : 20 min


Points to remember : 1) simply tick mark the option which is correct.
2) +2 for right answer -1 for wrong answer

Name: Roll No:

1. Let A be a square matrix of size n x n. Consider the following program. What is the expected output?

​ = 100
C
for i = 1 to n do
for j = 1 to n do
{
Temp = A[i][j] + C
A[i][j] = A[j][i]
A[j][i] = Temp - C
}
for i = 1 to n do
for j = 1 to n do
Output(A[i][j]);

a)​ The matrix A itself b)​ Transpose of matrix A

c)​ Adding 100 to the upper diagonal elements and subtracting d)​ None of the above
100 from diagonal elements of A

2. ​The inorder and preorder traversal of a binary tree are d b e a f c g and a b d e c f g, respectively. The
postorder traversal of the binary tree is:

a)​ d e b f g c a b)​ e d b g f c a

c)​ e d b f g c a d)​ d e f g b c a

3. ​Which of the following operations is not O(1) for an array of sorted data. You may assume that array
elements are distinct.

a)Find the ith largest element b) Delete an element

c) Find the ith smallest element d) All of the above

4. ​The minimum number of comparisons required to determine if an integer appears more than n/2 times in a
sorted array of n integers is

(A) (n)

(B) (logn)

(C) (log*n)

(D) (1)

a) A b) B

c) C d) D
5. ​Match the problem domains in GROUP I with the solution technologies in GROUP II
GROUP I GROUP II
(P) Service oriented computing (1) Interoperability
(Q) Heterogeneous communicating systems (2) BPMN
(R) Information representation (3) Publish-find-bind
(S) Process description (4) XML

a) P-1, Q-2, R-3, S-4 b) P-3, Q-1, R-4, S-2

c) P-3, Q-4, R-2, S-1 d) P-4, Q-3, R-2, S-1

6. What is the output of this C code?


#include <stdio.h>
int main()
{
int i = 10;
void *p = &i;
printf("%f\n", *(float*)p);
return 0;
}

a) Compile time error b) Undefined behaviour

c) 10 d) 0.000000

7. ​Following function is supposed to calculate the maximum depth or height of a Binary tree -- the number of
nodes along the longest path from the root node down to the farthest leaf node.
int maxDepth(struct node* node)
{
if (node==NULL)
return 0;
else
{
/* compute the depth of each subtree */
int lDepth = maxDepth(node->left);
int rDepth = maxDepth(node->right);

/* use the larger one */


if (lDepth > rDepth)
return X;
else return Y;
}
}

a) X = lDepth, Y = rDepth b) X = lDepth + 1, Y = rDepth + 1

c) X = lDepth - 1, Y = rDepth -1 d) None of the above

8. ​Which of the following pairs of traversals is not sufficient to build a binary tree from the given traversals?

a) Preorder and Inorder b) Preorder and Postorder

c) Inorder and Postorder d) None of the Above

9. What is the output of this C code?


​#include ​<stdio.h>
​int​ main()
{
​int​ ary[​2​][​3​];
foo(ary);
}
​void​ foo(​int​ (*ary)[​3​])
{
​int​ i = ​10​, j = ​2​, k;
ary[​0​] = &i;
ary[​1​] = &j;
​for​ (k = ​0​;k < ​2​; k++)
printf(​"%d\n"​, *ary[k]);
}

a) Compile time error b) 10 2

c) Undefined behaviour d) segmentation fault/code crash

10. ​Given an unsorted array. The array has this property that every element in array is at most k distance from its position in sorted array
where k is a positive integer smaller than size of array. Which sorting algorithm can be easily modified for sorting this array and what is the
obtainable time complexity?

a) Insertion Sort with time complexity O(kn) b) Heap Sort with time complexity O(nLogk)

c) Quick Sort with time complexity O(kLogk) d) Merge Sort with time complexity O(kLogk)

11. ​Given the basic ER and relational models, which of the following is INCORRECT?

a) ​An attribute of an entity can have more than one value b) ​An attribute of an entity can be composite

c) ​In a row of a relational table, an attribute can have more than one value d) ​In a row of a relational table, an attribute can have
exactly one value or a NULL value

12. ​Given 8 identical coins out of which one coin is heavy and a ​pan balance​. How many minimum number of measurements are needed to
find the heavy coin?

a) 2 b) 3

c) 4 d) 7

13. ​In a village, people build houses in the same side of the road. A thief plans to loot the village. He wants maximum amount of money
without having any risk of getting caught. By some means, the villagers know that their adjacent house is being looted or not and thus they
become alert. So the thief cannot loot contiguous two houses. Given that the thief knows the amount of money stored in each house and
the road is straight and there is no turning, which is the most efficient algorithmic strategy to solve this problem?

a) Brute-force b) Dynamic Programming

c) Backtracking d) Divide and Conquer

14. ​Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic values. F = {CH -> G, A -> BC, B -> CFH, E -> A, F -> EG}
is a set of functional dependencies (FDs) so that F+ is exactly the set of FDs that hold for R. How many candidate keys does the relation R
have?

a) 3 b) 4

c) 5 d) 6
15. ​Which of following statements is/are False?
1. XML overcomes the limitations in HTML
to support a structured way of organizing content.

2. XML specification is not case sensitive while


HTML specification is case sensitive.

3. XML supports user defined tags while HTML


uses pre-defined tags.

4. XML tags need not be closed while HTML


tags must be closed.

a) 2 only b) 1only

c) 2 and 4 only d) 3 and 4 only

16.
Table A
Id Name Age
----------------
12 Arun 60
15 Shreya 24
99 Rohit 11

Table B
Id Name Age
----------------
15 Shreya 24
25 Hari 40
98 Rohit 20
99 Rohit 11

Table C
Id Phone Area
-----------------
10 2200 02
99 2100 01
Consider the above tables A, B and C. How many tuples does the result of the following SQL query contains?
SELECT A.id FROM A WHERE A.age > ALL (SELECT B.age FROM B WHERE B. name = "arun")

a) 4 b) 3

c) 0 d) 1

17) ​Database table by name Loan_Records is given below.


Borrower Bank_Manager Loan_Amount
Ramesh Sunderajan 10000.00
Suresh Ramgopal 5000.00
Mahesh Sunderajan 7000.00
What is the output of the following SQL query?
SELECT Count(*)
FROM ( (SELECT Borrower, Bank_Manager
FROM Loan_Records) AS S
NATURAL JOIN (SELECT Bank_Manager,
Loan_Amount
FROM Loan_Records) AS T );

a) 3 b) 9

c) 5 d) 6

18) ​If a class B network on the Internet has a subnet mask of 255.255.248.0, what is the maximum number of hosts per subnet?

a) ​1022 b) ​1023

c) ​2046 d) ​2047
19) ​There are 25 horses among which you need to find out the fastest 3 horses. You can conduct race among at most 5 to find out their
relative speed. At no point you can find out the actual speed of the horse in a race. Find out how many races are required to get the top 3
horses.

a) 5 b) 6

c) 7 d) 8

20) ​What does the following function do for a given binary tree?
int fun(struct node *root)
{
if (root == NULL)
return 0;
if (root->left == NULL && root->right == NULL)
return 0;
return 1 + fun(root->left) + fun(root->right);
}

a) Counts leaf nodes b)Counts internal nodes


c) Returns height where height is defined as number of edges on d) Return diameter where diameter is number
the path from root to deepest node of edges on the longest path between any two
nodes

Vous aimerez peut-être aussi