0% found this document useful (0 votes)
52 views12 pages

Cap 2 PDF

Uploaded by

Kaushiki Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views12 pages

Cap 2 PDF

Uploaded by

Kaushiki Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Capgemini Pseudocodes-II

Q1.

int a, b;
a = 1;
while (a <= b)
a = a*2;

The number of comparisons made in the execution of the loop for any n > 0 is:

Base of Log is 2 in all options.

a) CEIL(logb) + 2
b) b
c) CEIL(logb)
d) FLOOR(logb) + 2

Q2.

A list/Array contains random numbers what will be the time complexity to pickout a number
that is neither maximum nor minimum

a) Θ(nlogn)
b) Θ(n)
c) Θ(logn)
d) Θ(1)

Q3. The minimum number of comparisons required to find the minimum and the maximum
of 200 numbers is ______________.

a) 198
b) 400
c) 298
d) 240

Q4.
Suppose that we have numbers between 1 and 100 in a binary search tree and want to
search for the number 55. Which of the following sequences CANNOT be the sequence of
nodes examined?

a) {10, 75, 64, 43, 60, 57, 55}


b) {90, 12, 68, 34, 62, 45, 55}
c) {9, 85, 47, 68, 48, 57, 55}
d) {79, 14, 72, 56, 76, 53, 55}
Q5. What will be the output?
char c[] = "Capgemini";
char *p = c;
printf ("%s",p + p[3]- p[1]);

a)001
b)G
c)ini
d)mini

Q6.
#include<stdio.h>
int main()
{
int mul=1,i;
for(i=1;i<=7;i++)
{
mul=mul*i;
if(i==3)
continue;
if(i==4)
goto multiply;
}
multiply:
printf("%d\n",mul);
return 0;
}

a)120
b)24
c)20
d)Error
Q7. What will be the output if n=4?
int fun(int n)
{
int x=1, k;
if (n==1)
return x;
for (k=1; k<n; ++k)
x = x + fun(k) * fun(n-k);
return x;
}
int a=fun(5);
printf("%d",a);

a)Error
b)15
c)51
d)0

Q8.
#include <stdio.h>
void main()
{
int a = 10;
int *b = &a;
int **c = &b;
printf("%d %d %d", a, *b, *&c);
}

a)10 10 random_value
b)10 10 10
c)random_value random_value random_value
d)Error

Q9.
#include <stdio.h>
void function( int *num1)
{
for(int x=0; x<5; x++)
{
printf(" %d ",*num1);
num1++;
}
}
int main()
{
int number[] = {10, 20, 30, 40, 50};
function(number);
return 0;
}

a)11 22 33 44 55
b)10 20 30 40 50
c)11 12 13 14 15
d)Error

Q10.
#include<stdio.h>
int main()
{
int i = 11;
void *p = &i;
printf("%f",p);
}

a)0
b)0.0000
c)11
d)Address value

Q11.
#include<stdio.h>
int main()
{
char str[25] = "Capgemini";
printf("%s\n", str+2);
return 0;
}

a)Capgemini2
b)Cap
c)pgemini
d)gemini

Q12 What will be the output

Limit = 5
n1 = 0, n2= 1, n3=1, count = 1;
while count <= limit
count=count+1
print n3
n3 = n1 + n2
n1 = n2
n2 = n3
End While
a)1123
b)11235
c)12345
d)11234

Q13.
If the address of A[1][1] and A[2][1] are 2000 and 2010 respectively and each element
occupies 2 bytes then the array has been stored in _________ order. What is the number of
columns in array.

a)Row Major, 5
b)Column Major, 5
c)Row Major , 10
d)Row Major , 10

Q14. Which of the following min heap visualization is correct.

a)1 2 6 21 11 14 17 19 10
b) 1 2 17 10 11 14 6 19 21
c) 2 1 6 10 11 14 17 19 21
d) 1 2 6 10 11 14 17 19 21

Q15. If the base address of a two dimensional array A[30][40] is 500, then find out the
address of an element A[4] [3] the Assume 4 words per memory cell and elements are
arranged in row major order.

a)956
b)1156
c)952
d)1056

Q16.What will be the output


#include<stdio.h>
main()

{
int n,i;
n=f(6);
printf("%d",n);
}

f(int x)
{
if(x==2)
return 7;

else
{
printf("+");
f(x-1);

}
}
a) ++++7
b) ++++2
c) +++++7
d) +++7

Q17.What will be the output.


#include<stdio.h>

main()
{
int n=7;
int f(int n);

printf("%d",f(n));
}
int f(int n)
{

if(n>0)
return(n+f(n-2));
}
a)30
b)20

c)15
d)60

Q18. Construct a binary tree by using postorder and inorder sequences given below.
Inorder: N, M, P, O, Q
Postorder: N, P, Q, O, M
a)

b)

c)
d)

Q19.

If we draw a binary search tree by inserting the given numbers from left to right. then what
would
be the height of the BST?
175683

a)4
b)3
c)5
d)6

Q20. What will be the output.


#include <iostream>

using namespace std;

int main()

int a = 31, *ptr = &a;

char ch = 'Z', &cho = ch;

cho += a;

*ptr += ch;

cout << a << ", " << ch << endl;

return 0;

}
a)152, z
b)152, Z
c)150, y

d)152, y

Q21.Given is the array representation of max heap what will be the representation after
inserting 80 tin heap?

90 72 88 17 35 12
a) 90 72 80 88 17 35 12
b) 90 80 88 72 17 35 12
c) 90 72 88 17 35 80 12
d) 90 72 88 17 35 12 80

Q22. Convert the following Infix expression to postfix.


A+B*C/(E-F)+G
a) ABC*EF-G+/+

b) ABC*EF-/+G+
c) ABC*+GEF-/+
d) ABC*+GEF-/-

Q23.

Counter=2,i
For i (0 to 1<< 2)
Counter = Counter * 2
END For
Print Counter

a)64

b)32

c)128

d)16

Q24.

Integer a, b, c
Set b = 1051, a = 1
c=a^b
c=c&1024
c=c|3
Print c

a)1027
b)1025
c)1051
d)1057
Q25
Which of the following statements is incorrect for Linked list data structure?

a) Memory allocation from Heap


b) Memory allocation from stack
c) Size is not fixed.
d) It occupies more memory than array

Q26 If you are using Bubble sort for sorting the given numbers in ascending order, then find
out the number of swapping needed.
3,10,4,7,9,2,6

a) 12
b) 14
c) 11
d) 8

Q27 Evaluate the given postfix expression.


10 5 4 2 + 5 * + 2 + *
a) 220
b) 280
c) 380
d) 370

Q28 Which of the following statements is/are TRUE for array data structure?
a)Memory allocation from stack.
b)Memory allocation from Heap
c) All of the mentioned options.
d)Size is not fixed.

Q29. Find out the array representation of the given max heap, if the value 20 is deleted from
it.
22,21,20,19

a) 21,22,19
b) 22,21,19
c) 19,21,22
d) 21,19,22
Q30. In a min heap, the left child is located at:

a) 2*k index
b) (k+1)/2 index
c) k/2 index
d) 2*k+1. Index
Answers:

1. D
2. D
3. C
4. D
5. C
6. B
7. B
8. A
9. B
10. B
11. C
12. B
13. A
14. D
15. B
16. A
17. C
18. D
19. A
20. D
21. D
22. B
23. A
24. A
25. B
26. C
27. D
28. B
29. B
30. D

You might also like