Академический Документы
Профессиональный Документы
Культура Документы
BASIC C
CONTROL STATEMENTS
1.What will be the output of the following C code?
#include<stdio.h>
Int main()
{
Int x=0;
If(x==1)
If(x==0)
Printf(“inside if \n”);
Else
Printf(“inside else if\n”);
Else
Printf(“inside else\n”);
}
OPS:
a.inside if
b.inside else
c.compilation error
d.inside else if
OPS:
a.2
b.1
c.hello world
d.4
OPS:
a. compilation error
b. 3
c.1
d. Runtime error
OPS:
a.12
b.4
c.16
d.5
OPERATORS
1.What will be the output of the following code ?
#include<stdio.h>
Void main()
{
Int x=9,y=2,z=6;
Int a= x & y | z;
Printf(“%d”,a);
}
Ops:
a.2
b.3
c.0
d.6
2. What would be the output of the following c code?
#include<stdio.h>
Int main()
{
Int x=4,y=0;
Int z;
Z=(y++,y);
Printf(“%d\n”,z);
Return 0;
}
OPS:
a.1
b. undefined behavior due to order of evaluation can be different
c.0
d.compliation error
3.what will be the output of the following c code?
#include<stdio.h>
Int main()
{
Int y=5;
Int z=y+(y=10);
Printf(“%d\n”,z);
}
OPS:
a.20
b.4
c.either 12 or 20
d.12
POINTERS
1. What will be the output of the following code ?
Main()
{
Int num[]={1,4,8,12,16};
Int *a,*b;
Int I;
A=num;
B=num+2;
I = *a++;
Printf(“%d,%d,%d\n”,I,*a,*b);
}
OPS:
a.4,4,8
b.2,4,8
c.1,4,8,
d.2,1,,8
2. comment on the output of the following c code ?
#include<stdio.h>
Void main()
{
Int k=4;
Int *const p=&k;
Int r=3;
P=&r;
Printf(“%d”,p);
}
OPS:
a.it will print address of r
b.it will print address of k+ address of r
c. it will print address of k
d.complie time error
OPS:
a.only the front will change
b.none of them will change
c.only the rear will change
d.both will change
2.In which of the following situations queue implementation is usefull?
OPS:
A. All the mentioned options
B. When data is transferred asynchronously between two processes
C.When a resource is shared among multiple consumers.
D. Load balancing.
LINKED LISTS
1.What will be the probability of selecting a random node from a given singly linked
list?(Assume that there are n nodes in the list)
OPS:
a.2(n-1)/n
b.n/2(n-1)
c.2n-1
d.1/n
GRAPH
1.What is the maximum degree of any vertex in a simple graph with n vertices.?
OPS:
a.2n-1
b.n-1
c.n+1
d.n
2. which of the following statements is /are TRUE for undirected graph?
P: Number of odd degree vertices is even
Q: sum of degree of all vertices is even
OPS:
a.both of P and Q.
b. neither P nor Q.
C. Q only.
d. P only.
STACK
1.Identify the point that is not true with respect to stack?
OPS:
a.It is not possible to insert or remove elements anywhere else except the top of the
stack.
b.stack is a dynamic set where elements are removed in the reverse order of their
insertions.
c.All the mentioned options are correct
d.Stack supports LIFO order of deletion of items
2.which of the following applications may use a stack?
OPS:
a. A parntheseis is balancing program
b. Syntax analyser for a compiler
c. Keeping track of local varaiables at run time
d. All the mentioned options
TREES
1.Maximum height of an AVL tree with 7 node is?
OPS:
a.5
b.4
c.6
d.3
2. Which of the following is a direct search technique?
OPS:
a.Binary search
b.Linear search
c. Tree search
d.Hashing
3. Consider a Binary Tree having two pointers for each of its children. These
pointers are set to NULL if the corresponding child is empty. How many NULL
pointers does a binary tree with N nodes have?
OPS:
a. N-1
b. The number depends on the shape of the tree.
c. N
d. N+1
ALGORITHM
1. Consider the following functions and their complexities:
F1(n)=2n
F2(n)=n3/2
F3(n)=n Log n
F4(n)=nLog n
Which among the following options correctly represents the increasing order of
asymptotic complexity of the functions F1,F2,F3,F4 Respectively?
A. None of the mentioned options
B. F2<F3<F1<F4
C. F3<F2<F1<F4
D. F3<F2<F4<F1
ARRAY
1. Find out the number of interchanges needed to convert the given array into a
max-heap.
89,19,50,17,12,15,2,5,7,11,6,9,100
OPS:
a.2
b.5
c.3
d.4
ALGORITHM-LANGUAGE INDEPENDENT
RECURSION
1. What does the run() do in general?
1. int fun ( int x, int y)
2. {
3. if ( y = = 0) return 0;
4. return (x + fun (x, y-1));
5. }
6.
7. int run ( int a, int b)
8. {
9. if ( b == 0) return 1;
10. return fun ( a, b-1));
11. }
A. calculate X+X*Y
B. calculate X^Y
C. calculate X*Y
D. calculate y ^ X
3.What will be the output f the following pseudo code?
Input f=6,g=9 and set sum=0
Integer n
if(g>f)
for(n=f;n<g;n=n+1)
sum=sum+n
end for loop
else
print error message
print sum
OPS:
a.15
b.21
c.9
d.6
5.Consider the following pseudo code
a:=1;
b:=1;
while (a<=500)
begin
a:=2^a;
b:=b+1;
end
What is the value of b at the end of the pseudo code?
OPS:
a.7
b.5
c.4
d.6
7.The following pseudocode can be used for :
Let LB be the lower bound and UB be the upper bound of a linear array A.
[Initialize counter ]set k at lower bound LB
Repeat for k=LB to UB
Print a[k]
[End of the loop]
Exit
OPS:
a.Deleting an element from an array
b.Sorting an array
c.Traversing an array
d. Inserting elements in the array
8. What will be the output of the following algorithm for number =10?
Start
Declare the variable I,j,and num
Enter the value of num
Repeat for i=1 to num
Declare the static variable sap and set sap=0
sap=sap+i
j=sap
end loop
print j
Note: static allows the last value of the variable to be preserved between successive
function calls.
OPS:
a.85
b.75
c.65
d.55
9.What will b output of the following pseudocode?
Input:s
algorithm(integer num)
set integer i=2
while i<=num/2
if num mod i=0
print”Unsuccessful” and exit;
i=i+1
if (i==(num/2)+1)
print”Successfull”
OPS:
a.Successful
b.Unsuccessful
c.It will not print anything
d. Undefined behaviour of the algorithm
DYNAMIC PROGRAMMING
OPS:
a.it will display two if z is <=y
b.it will display 2 if x>y>z
c.it will display 4 if x>y<z
d.it will display 4 if x<=y
14. what will be the output of the following pseudo code for input 7?
Read the value of N
Set m=1, T=0;
If m>n
Go to line no 9
Else
T=T+m
M=m+1
Go to line no 3
Display the value of T
Stop
OPS:
a.28
b.76
c.32
d.56
OPS:
a.56
b.88
c.72
d.None of the mentioned
e.65
15.what will be the output of the following code if the value of n1 and n2 are 12,30
respectively?
Declare integer variables n1,n2 ,I ,j and flag
Read the values of n1 and n2
For i=n1+1 to (n2-1)
Set flag equals to 1
For j=2 to i/2
If I mod j equals to 0 then set flag =0
Break
End if
End for
If flag equals to 1 then print i
End if
Set i=i+1
End for
Stop
OPS:
a.will print all the values from 12 to 30
b. 13 17 19 23
c.13 15 17 19 21 23 25 27 29
d.12 15 18 21
16. what will be the output of the following algorithm?
Start
Declare a,I,and b
For I=0 to 4
Increment a by 1
If I=3 then
Print hello
Get out of the loop
End if
End for
Print a
OPS:
a. hello4
b. hello
c. 1
d. 4
18. What will be the output of the following algorithm?
Start
Declare v ariable f,g and i
Set f=0 and g=1
For i=1 to 4
Print f
F=f+g
G=f+g
End
OPS:
a. 0 1 1 2
b. 0 1 1 8
c. 0 1 3 8
d. 0 2 5 8
19. What will be the output of the following pseudocode?
OPS:
a. 0 1 3 8
b. 0 1 2 4
c. 0 1 2 3
d. 1 0 2 4
23. What will be output of the following algorithm for the input x=22 and y=3?
Start
Declare x,y,m,n
Set m=x and n=y
While m not equal to n then
If m greater than n
M=m-1
Otherwise
N=n-1
End if
End while
Print n
OPS:
a.12
b.3
c.4
d.None of the mentioned options
SORTING
11. What will be the necessary condition to get the desired element fom a given
array by using the following algorithm?
OPS:
a.The elements in the array should be in the sorted form
b.The array should contain more than one elements
c.No pre condition is required for the algorithm to work
d. The elements in the array should be in unsorted form
MultiDequeue(Q)
{
n=k
while (Q is not empty) and (n>0)
{
Dequeue (Q)
n = n-1
}
}
What is the worst-case time complexity of a sequence of ‘m’ MultiDeque()operations
on an initially empty queue?
OPS:
a. θ(m+k)
b. θ(mk)
c. θ(m^2)
d. θ(m)
DIGITAL LOGIC
FLIP FLOPS
1. How many flip-Flops are required for mod-16 counter?
A. 3
B. 4
C. 6
D. 5
2. Which one correctly defines Full-Adder?
OPS:
a. An adder circuit having two inputs used to add two binary digits.It produces
their sum and carry as input.
b. An adder circuit having three inputs used to add two binary digits plus a carry.It
produces their sum and carry as output.
c. An adder circuit used in the least significant position when adding two binary
digits with no carry into consider.It produces their sum and carry as outputs.
d. An adder circuit having two inputs and two outputs
LOGIC GATES
3. If we add NOT gate to the inputs of the And gate then it becomes?
a. A OR gate
b.A NAND gate
c.A XOR gate
d.A XNOR gate
ANALOG AND DIGITAL CONVERTERS
4.In order to build a 3 bit simultaneous A/D converter,what is the number of
comparator circuits required?
OPS:
a.7
b.8
c.15
d.16
MULTIPLEXER AND DEMULTIPLEXER
5.A demultiplexer can be used as a/an?
OPS:
a.decoder
b.AND gate
c.XOR gate
d.latch
NUMBER SYSTEM
6.The decimal number 38 in its binary form would be equivalent to?
OPS:
a.000110
b.101110
c.100111
d.100110