0% found this document useful (0 votes)
2K views18 pages

Pseudocode

The document contains 23 questions related to pseudo code, binary trees, sorting algorithms, and other computer science concepts. Each question has 4 multiple choice options for the output or answer.

Uploaded by

VIJAY kumar
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)
2K views18 pages

Pseudocode

The document contains 23 questions related to pseudo code, binary trees, sorting algorithms, and other computer science concepts. Each question has 4 multiple choice options for the output or answer.

Uploaded by

VIJAY kumar
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/ 18

1. What will be the output of the following pseudo code for a=1 b=4?

1.
2.Integer funn(Integer a, Integer b)
3. if((4-a)>(a-b) && (4-b)<(b-a))
4. a=(a+2)+a
5. b=2+3+a
6. Return funn(b,b)+b
7. End if
8. Return b+1

Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value
true( or 1) if both operands are true (or 0) otherwise.

Options:
A. 19
B. 23
C. 26
D. 17
Ans: A. 19

2. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=3, q=3, r=7
3. for( each r from 5 to 7)
4. p=9+p
5. End for
6. Print p+q

Options:
A. 34
B. 20
C. 46
D. 33
Ans: D. 33

3. Solve the given prefix expression.


542 / - 2 +
Options:
A. 8
B. 5
C. 2
D. 3
Ans: B. 5
4. Find the parent of J from the given linear or array representation of the binary tree.

A B C D F G H I J . . . K

Options:
A. D
B. F
C. G
D. H
Ans: A. D

5. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=3, q=5, r=5
3. r=(1+11)^p
4. r+(1&3)&p
5. p=(q&p)&p
6. p=(r+q)^p
7. Print p+q+r

Note- &: bitwise AND - The bitwise AND operator (&) comp operand. If both bits are
1, the corresponding result bit is ^ is the bitwise exclusive OR operator that compares
each bit of its first operand to the corresponding bit is 0 and other bit is 1 , the
corresponding result bit is set.

Options:
A. 12
B. 13
C. 22
D. 14
Ans: C. 22

6. Determine which of the given sequence of degree of vertices is graphic.


I.(2,3,3,4)
II.(2,2,3)

Note: A sequence is graphics if there is a simple graph with the degree sequence.

Options:
A. Only I
B. Neither I Nor II
C. Both I and II
D. Only II
Ans: A. Only I
7. What will be the output of the following pseudo code for a=7 b=3?

1.
2.Integer funn(Integer a, Integer b)
3. if((5-b)>(b-a) && a>6)
4. a=b+3
5. b=(b+1)+a
6. return funn(a,b+1)
7. End if
8. return a+1

Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value
true( or 1) if both operands are true (or 0) otherwise.

Options:
A. 10
B. 7
C. 13
D. 3
Ans: B. 7

8. What will be the output of the following pseudo code for a=6, b=1?

1.
2.Integer funn(Integer a, Integer b)
3. if((a-b)<(b^a) && b(a)
4. b=b+2
5. b=(a+3)+b
6. a+a+1
7. Return b-funn(b,b)
8. End if
9. Return b-a

Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value
true( or 1) if both operands are true (or 0) otherwise.
^ is the bitwise exclusive OR operator that compares each bit of its first operand to
the corresponding bit is 0 and other bit is 1 , the corresponding result bit is set.
Options:
A. 12
B. 31
C. 7
D. 13
Ans: A. 12
9. What will be the output of the following pseudo code for a=1, b=9?

1.
2.Integer funn(Integer a, Integer b)
3. if((b+a)>(a&b) && (a-b)<(b^a))
4. b=b+2
5. a=(a+2)+b
7. Return funn(b,b) -a
8. End if
9. Return a

Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value
true( or 1) if both operands are true (or 0) otherwise.
^ is the bitwise exclusive OR operator that compares each bit of its first operand to
the corresponding bit is 0 and other bit is 1 , the corresponding result bit is set.
Options:
A. 1
B. 7
C. -3
D. -4
Ans: C. -3

10. What will be the output of the following pseudo code?

1.
2.Integer
3. Integer arr[2][2]= {{2,2},{1,3}}
4. If ((arr[1][0]+arr[0][0])<(arr[0][1]-arr[1][1]))
5. arr[0][1]= (arr[0][1]+4)^arr[0][1]
6. End if
7. arr[1][1]=2+arr[1][1]
8. If ((1-arr[0][1]=arr[1][1])<(arr[1][1]+arr[0][1]))
9. arr[0][1]=(4^11)&arr[0][1]
10. End if
11. Print arr[0][1]+arr[0][1]

Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value
true( or 1) if both operands are true (or 0) otherwise.
^ is the bitwise exclusive OR operator that compares each bit of its first operand to
the corresponding bit is 0 and other bit is 1 , the corresponding result bit is set.
Options:
A. -1
B. 4
C. 6
D. 12
Ans: B. 4
11. What will be the output of the following pseudo code?

1.
2.Integer
3. Integer arr[2][2]= {{2,2},{1,4}}
4. arr[1][0]=(7^2) =arr[1][1]
5. If ((arr[1][1]+arr[0][0])<(arr[0][1]-arr[1][1]))
6. arr[0][1]xarr[0][1]+arr[0][1]
7. Else
8. arr[1][1]=(9+4+arr[0][1]
9. arr[0][1]=arr[1][1]&arr[0][1]
10. End if
11. arr[0][1]=(arr[1][1]&arr[0][1])&arr[0][1]
11. Print arr[0][1]+arr[0][1]

Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value
true( or 1) if both operands are true (or 0) otherwise.
^ is the bitwise exclusive OR operator that compares each bit of its first operand to
the corresponding bit is 0 and other bit is 1 , the corresponding result bit is set.
Options:
A. 3
B. 4
C. 12
D. 10
Ans: B. 4

12. Find out the number of vertices in a simple graph, if there are 10 edges, 4 vertices of
degree 2 and others of degree 3.
Options:
A. 9
B. 10
C. 7
D. 8
Ans: D. 8

13. Find out the address of element A[3][6] in a 2D array A[7][7] whose base address is 100
and elements are arranged in column major order. Assume 2 words per memory cell.
Options:
A. 155
B. 190
C. 112
D. 172
Ans: B. 190

14. Find out the array representation of the given minimum heap, if the value 51 is deleted
from it. 36, 42, 41, 52, 63, 51, 60.
Options:
A. 36, 42, 41, 52, 63, 60
B. 36, 52, 41, 42, 63, 60
C. 36, 42, 52, 41, 63, 60
D. 36, 52, 42, 41, 63, 60
Ans: A. 36, 42, 41, 52, 63, 60

15. What will be the output of the following pseudo code?

1.
2.Integer j
3. Integer arr[2][2]= {{2,2},{4,1}}
4. If ((arr[1][1]&arr[0][0])&arr[0][1])<arr[0][1]&3))
5.. arr[0][1]=(5+8)+arr[0][1]
6. arr[1][0]=1+arr[0][1]
7. End if
8. arr[0][1]=1+arr[1][0]
9. Print arr[1][0]+arr[0][1]

Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value
true( or 1) if both operands are true (or 0) otherwise.
^ is the bitwise exclusive OR operator that compares each bit of its first operand. If
Both bits are 1, the corresponding result bit is set to 0.
Options:
A. 33
B. 32
C. 36
D. 26
Ans: A. 33

16. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=3, q=3, r=7
3. for( each r from 5 to 7)
4. p=9+p
5. End for
6. Print p+q

Options:
A. 46
B. 33
C. 20
D. 34
Ans: B. 33

17. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=7, q=6, r=6
3. q=r&r
4. for( each r from 3 to 5)
5. q=12^q
6. End for
7. r=(r+q)&r
6. Print p+q

Options:
A. 13
B. 22
C. 16
D. 11
Ans: C. 16

18. What will be the output of the following pseudo code?

1. Integer a,b,c
2. Set a=0, b=2, c=9
3. if((b+c+9)<(4+a+b))
4. c=(10+1)+c
5. End if
6. c=(1+3)+a
7. Print a+b+c

Options:
A. 6
B. -1
C. 7
D. 18
Ans: A. 6

19. What is the maximum number of nodes at level 4 in a binary tree?

Options:
A. 32
B. 8
C. 16
D. 4
Ans: B. 8

20. What is the maximum number of nodes at level 7 in a binary tree?

Options:
A. 128
B. 32
C. 16
D. 64
Ans: D. 64
21. Find out the number of swappings required for sorting the given numbers in ascending
order if you are using bubble sort for sot=rting. 14, 8, 15, 12, 10.

Options:
A. 6
B. 8
C. 5
D. 7
Ans: A. 6

22. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=6, q=3, r=6
3. r=(p+11)^q
4. for( each r from 5 to 7)
5. q=(12+9)+r
6. End for
7. for(each r from 3 to 4)
8. q=(2^3)+r
9. q=q&q
10. End for
11. q=q+r
12. Print p+q

Note- &: bitwise AND - The bitwise AND operator (&) compares each bit of the first
operand to the corresponding bit of the second operand. If both bits are 1, the
corresponding result bit is set to 0.

^ is the bitwise exclusive OR operator that compares each bit of its first operand to
the corresponding bit to its second operand. If bit is 0 and other bit is 1 , the
corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.

Options:
A. 16
B. 21
C. 11
D. 28
Ans: A. 16

23. Solve the given postfix expression.


442 - + 3 /
Options:
A. 4
B. 6
C. 3
D. 2
Ans: C. 3
24. Find out the address of element A[7][8] in a 20 array A[8][10] whose base address is 100
and elements are arranged in row major order.
** assume 2 words per memory cell.

Options:
A. 567
B. 256
C. 789
D. 234
Ans: B. 256

25. What will be the output of the following pseudo code?

1.
2.Integer j
3. Integer arr= {1,3,1,5}
4. arr[0]=(arr[2]+arr[0])+arr[0]
5. if ((arr[3]^8)<8)
6.. arr[1]=4+arr[1]
7. End if
8. arr[0]=(arr[2]+arr[0])+arr[2]
9. If(arr[0]<arr[1])
10. arr[2]=arr[2]+arr[0]
11. Else
12. arr[1]=4+arr[1]
13. End if
14. Print arr[1]+arr[2]+arr[3]

Note- ^ is the bitwise exclusive OR operator that compares each bit of its first
operand to the corresponding bit to its second operand. If bit is 0 and other bit is 1 ,
the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set
to 0.
Options:
A. 17
B. 8
C. 13
D. 24
Ans: C. 13

26. Determine which of the given sequence of degree of vertices is graphic.


I.(2,2,2)
II.(2,2,3,3)

Note: A sequence is graphics if there is a simple graph with the degree sequence.

Options:
A. Both I & II
B. Only II
C. Neither I Nor II
D. Only I
Ans: A. Both I & II

27. What will be the output of the following pseudo code for a=7 b=3?

1.
2.Integer funn(Integer a, Integer b)
3. if((5-b)>(b-a) && a>6)
4. a=b+3
5. b=(b+1)+a
6. Return funn(a,b+1)
7. End if
8. Return a+1

Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value
true( or 1) if both operands are true (or 0) otherwise.

Options:
A. 3
B. 13
C. 7
D. 10
Ans: C. 7

28. In which of the following data structure the relationship of adjacency is not maintained
between the data items?

Options:
A. Queue
B. Tree
C. Linked List
D. Stack
Ans: B. Tree

29. Find out the number of swappings required for sorting the given numbers in ascending
order if you are using bubble sort for sot=rting. 14, 8, 15, 12, 10.

Options:
A. 5
B. 7
C. 8
D. 6
Ans: D. 6

30. What will be the output of the following pseudo code?

1. Integer a,b,c
2. Set a=6, b=3, c=6
3. For (each c from 4 to 7)
4. b=10&a
5. a=(3+1)+b
6. b=(b+5)+a
7. End if
8. Print a+b

Note- &: bitwise AND - The bitwise AND operator (&) compares each bit of the first
operand to the corresponding bit of the second operand. If both bits are 1, the
corresponding result bit is set to 0.

Options:
A. 16
B. 37
C. 19
D. 23
Ans: B. 37

31. Solve the given postfix expression.


742 - + 3 /
Options:
A. 3
B. 2
C. 4
D. 6
Ans: A. 3

32. What is the maximum number of nodes at level 8 in a binary tree?

Options:
A. 512
B. 128
C. 64
D. 256
Ans: D. 256

33. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=6, q=3, r=6
3. if((q+p+r)<(4+r+6))
4. r=(3+10)+q
5. if((9+q+4)<(4+9))
6. q=(2+2)+q
7. if((p+r+q)<(r+q+p))
8. r=(3+9)+q
9. Else
10. p=(p+r)+q
11. End if
12. r=(r+q)+r
12. End if
13. End if
14. Print p+q+r

Options:
A. 20
B. 32
C. 34
D. 25
Ans: D. 25

34. What will be the output of the following pseudo code?

1.
2. String s,s2, s1
3. Set s=’My’
4. Set s1=’Blog’
5. s2=s[:1]+s1[(string.length(s1))-1:]
6. print(s2)

Note- string.length(): string.length() function counts the number of characters in the given
string and returns.

Options:
A. My Blog
B. Mg
C. Yo
D. MyBlog
Ans: B. Mg

35. Determine which of the given sequence of degree of vertices is graphic.


I.(2,2,3)
II.(2,3,3)

Note: A sequence is graphics if there is a simple graph with the degree sequence.

Options:
A. Only I
B. Only II
C. Both I & II
D. Neither I Nor II
Ans: D. Neither I Nor II

36. What will be the output of the following pseudo code?


1. Integer a,b,c
2. Set a=6, b=3, c=6
3. if((8^3)<b)
4. if(a>c)
5. If ((a+c)<(c-a))
6. a=11^c
7. End if
8. b=(9a710)+c
9. Else
10. c=(c+a)+a
11. End if
12. a=(a+a)&b
13. End if
11. c=(b+11)&a
12. Print a+b+c

Note- &: bitwise AND - The bitwise AND operator (&) compares each bit of the first
operand to the corresponding bit of the second operand. If both bits are 1, the
corresponding result bit is set to 0.

^ is the bitwise exclusive OR operator that compares each bit of its first operand to
the corresponding bit to its second operand. If bit is 0 and other bit is 1 , the
corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.

Options:
A. 15
B. 22
C. 17
D. 13
Ans: A. 15

37. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=0, q=2, r=10
3. if((q^p^r)>(r^q))
4. q=(11^8)
5. p=(p+r)+q
6. End if
7. Print p+q+r

^ is the bitwise exclusive OR operator that compares each bit of its first operand to
the corresponding bit to its second operand. If bit is 0 and other bit is 1 , the
corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.

Options:
A. 18
B. 12
C. 29
D. 8
Ans: B. 12

38. Find out the array representation of the given minimum heap, if the value 684 is deleted
from it. 680, 684, 686, 1079, 1080.
Options:
A. 680,1080,1079, 686
B. 680, 1079, 686, 1080
C. 680, 1079, 686, 1080
D. 680, 1079, 1080, 686
Ans: B. 680, 1079, 686, 1080

39. Find the right child of 6 from the given linear or array representation of the binary tree.

15 6 18 3 7 17 20 2 4 13

0 1 2 3 4 5 6 7 8 9

Options:
A. 4
B. 7
C. 3
D. 2
Ans: B. 7

40. What will be the output of the following pseudo code?

1.
2.Integer j
3. Integer arr[2][2]= {{2,2},{4,1}}
4. If ((arr[1][1]&arr[0][0])&arr[0][1])<arr[0][1]&3))
5.. arr[0][1]=(5+8)+arr[0][1]
6. arr[1][0]=1+arr[0][1]
7. End if
8. arr[0][1]=1+arr[1][0]
9. Print arr[1][0]+arr[0][1]

Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value
true( or 1) if both operands are true (or 0) otherwise.
^ is the bitwise exclusive OR operator that compares each bit of its first operand. If
Both bits are 1, the corresponding result bit is set to 0.
Options:
A. 36
B. 26
C. 52
D. 33
Ans: D. 33

41. What will be the output of the following pseudo code for a=6 b=1?

1.
2.Integer funn(Integer a, Integer b)
3. if((a-b)<(b^a) && b<a)
4. b=b+2
5. b=(a+3)+b
6. a=a+1
7. Return b-funn(b,b)
8. End if
9. Return b-a

Note- Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean
value true( or 1) if both operands are true (or 0) otherwise.
^ is the bitwise exclusive OR operator that compares each bit of its first operand. If
Both bits are 1, the corresponding result bit is set to 0.

Options:
A. 31
B. 13
C. 7
D. 12
Ans: D. 12

42. What will be the output of the following pseudo code for a=7 b=3?

1.
2.Integer funn(Integer a, Integer b)
3. if((5-b)>(b-a) && a>6
4. a=b+3
5. b=(b+1)+a
6. Return funn(a,b+1)
8. End if
9. Return a=1

Note- Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean
value true( or 1) if both operands are true (or 0) otherwise.
^ is the bitwise exclusive OR operator that compares each bit of its first operand. If
Both bits are 1, the corresponding result bit is set to 0.

Options:
A. 13
B. 7
C. 10
D. 3
Ans: B. 7

43. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=6, q=3, r=6
3. r=(q+1)+p
4. if((q+p+r)<(4-q-r))
5. if((q+p)<(r+q))
6. if((6+4)<p)
7. p=(r+10)+r
8. End if
9. End if
10. r=(r+5)+r
11. Else
12. q=1+p
13. End if
14. Print p+q+r

Options:
A. 33
B. 25
C. 23
D. 21
Ans: C. 23

44. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=7, q=5, r=10
3. q+p+q
4. if((q&p&r)<(r&q))
5. r=3+q
6. Else
7. p=3+q
8. End if
9. r=p+r
10. iF (4<q)
11. r=7+r
12. End if
13. Print p+q+r

Note- Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean
value true( or 1) if both operands are true (or 0) otherwise.

Options:
A. 48
B. 43
C. 45
D. 42
Ans: A. 48

45. What will be the output of the following pseudo code?

1. Integer p,q,r
2. Set p=2, q=8, r=9
3. p=(r+q)&q
4. if((r+p)<(p-r) || 3>r
5. r=p+q
6. Else
7. p=(p&10)+q
8. End if
9. r=p+r
10. End if
11. Print p+q+r

Note- &: bitwise AND - The bitwise AND operator (&) comp operand. If both bits are
1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is
set to 0.
||: logical OR - The logical OR operator(||) returns the boolean value true (or 1) if
either or both operands is true and returns false(or 0) otherwise.

Options:
A. 50
B. 30
C. 23
D. 33
Ans: B. 30

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy