#include<stdio.
h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x <5)
continue;
else
break;
printf("SVES");
}
return0;
}
How many times “SVES” is printed
a. 0 times
b. 10 times
c. 11 times
d. Infinite times
4.
Predict output of following program
intmain()
{
inti;
intarr[5] = {1};
for(i = 0; i < 5; i++)
printf("%d ", arr[i]);
return0;
}
a. 1 followed by four garbage values
b. 10000
c. 11111
d. 00000
6. If we have a tree of n nodes, how many edges will it have?
a. 1
b. n-1
c. (n*(n-1))/2
d. (n*(n-1))
7.Which of the following data structures can handle updates and queries in log(n) time on an
array?
a. Stack
b. Queue
c. Linked List
d. Segment Tree
8.Pushing an element into stack already having five elements and stack size of 5 , then stack
becomes
a) Overflow
b) Crash
c) Underflow
d) User flow
9. What is the time complexity to count the number of elements in the linked list?
a) O(1)
b) O(n)
c) O(logn)
d) None of the mentioned
10. What is a hash function?
a) A function has allocated memory to keys
b) A function that computes the location of the key in the array
c) A function that creates an array
d) None of the mentioned
11. Recursion is similar to which of the following?
a) Switch Case
b) Loop
c) If-else
d) None of the mentioned
12. The output of the code below is
1. #include <stdio.h>
2. void main()
3. {
4. int x =5;
5. if(x <1)
6. printf("hello");
7. if(x ==5)
8. printf("hi");
9. else
10. printf("no");
11. }
a) hi
b) hello
c) no
d) None of the mentioned
15. Consider the following pseudo-code
x:=1;
i:=1;
while(x <=1000)
begin
x:=2^x;
i:=i+1;
end;
a. 4
b. 5
c. 6
d. 7
16. Consider the following pseudocode
x:=1;
i:=1;
while ( x ≤≤ 500)
begin
x:=2xx;
i:=i+1;
end
What is the value of i at the end of the pseudocode?
A. 4
B. 5
C. 6
D. 7
17. Consider the following pseudo- code
while(m<n)
if(x>y )and(a<b)then
a=a+1
y=y-1
endif
m=m+1endwhile
What is cyclomatic complexity of the above pseudo -code?
A. 2
B. 3
C. 4
D. 5
18. a sorted array of n elements contains 0 and 1. to find out majority of 0 and 1 how much ime it
will take?
1)O(1)
2)O(logn)
3)O(n)
4)O(n^2)
19. How many times is the comparison i>=n performed in the following program?
int i=85, n=5;
main(){
while(i >= n){
i=i-1;
n=n+1;
}
}
A. 40
B. 41
C. 42
D. 43
20. A binary tree T has 20 leaves. The number of nodes in T having two children is ______.
a. 21
b. 19
c. 40
d. 41