0% found this document useful (0 votes)
4K views

Write A Pseudocode To Find The Largest of Two Numbers

The document contains 12 pseudocode questions related to algorithms and data structures. The pseudocode questions cover topics like finding the largest of two numbers, calculating sums, areas of different shapes, and greatest of three numbers. Additional questions involve evaluating postfix expressions, sorting arrays using bubble sort, operations on binary trees and heaps.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4K views

Write A Pseudocode To Find The Largest of Two Numbers

The document contains 12 pseudocode questions related to algorithms and data structures. The pseudocode questions cover topics like finding the largest of two numbers, calculating sums, areas of different shapes, and greatest of three numbers. Additional questions involve evaluating postfix expressions, sorting arrays using bubble sort, operations on binary trees and heaps.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Pseudocode questions

1. WRITE A PSEUDOCODE TO FIND THE LARGEST OF TWO


NUMBERS.
2. BEGIN
3. NUMERIC nNum1,nNum2
4. DISPLAY "ENTER THE FIRST NUMBER :"
5. INPUT nNum1
6. DISPLAY "ENTER THE SECOND NUMBER : "
7. INPUT nNum2
8. IF nNum1 > nNum2
9. DISPLAY nNum1 + " is larger than "+ nNum2
10. ELSE
11. DISPLAY nNum2 + " is larger than " + nNum1
12. END

2. WRITE
A PSEUDOCODE TO FIND THE SUM OF TWO
NUMBERS.
begin

numeric nNum1,nNum2,nSum

display "ENTER THE FIRST NUMBER : "

accept nNum1

display "ENTER THE SECOND NUMBER : "

accept nNum2

compute nSum=nNum1+nNum2

display "SUM OF THESE NUMBER : " nSum

end

3. WRITE A PSEUDOCODE TO FIND THE AREA OF RECTANGLE.


begin

numeric nLen,nBrd,nAre

display "ENTER THE LENGTH OF RECTANGLE : "

accept nLen

display "ENTER THE BREADTH OF RECTANGLE : "

accept nBrd

nAre=nLen*nBrd

display "AREA OF RECTANGLE : " nAre

end
4. WRITE A PSEUDOCODE TO FIND THE AREA OF SQUARE.
begin

numeric nSide, nArea

display "ENTER THE SIDE OF SQUARE : "

accept nSide

nArea=nSide*nSide

display "AREA OF SQUARE : " nArea

end

5. WRITE A PSEUDOCODE TO FIND THE AREA OF CIRCLE.


begin

numeric nRad, nAre

display "ENTER THE RADIUS OF CIRCLE : "

accept nRad

nArea = nRad*nRad*22/7

display "AREA OF CIRCLE : " nArea

end

6. WRITE A PSEUDOCODE TO FIND THE AREA OF


PARALLELOGRAM.
begin

numeric nBase, nPerp, nArea

display "ENTER THE BASE : "

accept nBase

display "ENTER THE PERPENDICULAR : "

accept nPerp

nArea=nBase*nPerp

display "AREA OF PARALLELOGRAM : " nArea

end

7. WRITE A PSEUDOCODE TO FIND THE AREA OF TRIANGLE


begin

numeric nBase, nHigh, nArea

display "ENTER THE BASE OF TRIANGLE : "


accept nBase

display "ENTER THE HEIGHT OF TRIANGLE : "

accept nHigh

nArea=nBase*nHigh

display "AREA OF TRIANGLE : " nArea

end

8. WRITE A PSEUDOCODE TO FIND THE AREA OF RHOMBUS.


begin

numeric nDgn1, nDgn2, nArea

display "ENTER THE LENGTH OF FIRST DIAGONAL : "

accept nDgn1

display "ENTER THE LENGTH OF SECOND DIAGONAL : "

accept nDgn2

nArea=nDgn1*nDgn2/2

display "AREA OF RHOMBUS : " nArea

end

9. WRITE A PSEUDOCODE TO FIND THE GREATEST OF TWO


NUMBERS.
begin

numeric nNum1, nNum2

display "ENTER THE FIRST NUMBER : "

accept nNum1

display "ENTER THE SECOND NUMBER : "

accept nNum2

if(nNum1>nNum2)

begin

display "GREATEST ONE : " nNum1

end

else
begin

display "GREATEST ONE : " nNum2

end

end

10. WRITE A PSEUDOCODE TO FIND THE GREATEST OF TWO


NUMBERS USING TERNARY OPERATOR.
begin

numeric nNum1, nNum2

display "ENTER THE FIRST NUMBER : "

accept nNum1

display "ENTER THE SECOND NUMBER : "

accept nNum2

nGone=(nNum1>nNum2)?nNum1:nNum2

display "GREATEST ONE : " nGone

end

11. WRITE A PSEUDOCODE TO FIND THE GREATEST OF THREE


NUMBERS.
begin

numeric nNum1,nNum2,nNum3

display "ENTER THE FIRST NUMBER : "

accept nNum1

display "ENTER THE SECOND NUMBER : "

accept nNum2

display "ENTER THE THIRD NUMBER : "

accept nNum3

if(nNum1>nNum2)

begin

if(nNum1>nNum3)

begin

display "GREATEST ONE : " nNum1

end

else
begin

display "GREATEST ONE : " nNum3

end

end

else

if(nNum2>nNum3)

begin

display "GREATEST ONE : " nNum2

end

else

begin

display "GREATEST ONE : " nNum3

end
Capgemini Questions with Answers
Pseudocode Questions and Answers

ALGORITHMS
1. What will be the output of the following pseudo code?

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 1.
Otherwise, the corresponding result bit is set to 0.
A. 6
B. 24
C. 7
D. 11

Answer: C

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

A. 22
B. 18
C. 31
D. 13

Answer: B

P a g e 5 | 17
3. What will be the output of the following pseudocode?

Note: reverse(string) reverses the string, e.g. reverse(‘okay’) returns ‘Yako’.


countConso(string) returns the number of consonants in the string, e.g. countConso(“okay”) returns
2. upper(string) converts all the letters of the string to upper case, e.g. upper(“Okay”) returns “OKAY”.
A. 5
B. 10
C. 7
D. 4

Answer: A

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

A. 96
B. 15
C. 33
D. 26

Answer: B

5. What will be the output of the following pseudocode for a=2, b=7, c=7?

A. 26
B. 14
C. 16
D. 18

Answer: C

6. What will be the output of the following pseudocode for p=7, q=2?

P a g e 6 | 17
A. 20
B. 2
C. 12
D. 3

Answer: D

7. What will be the output of the following pseudocode?

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 1.
Otherwise, the corresponding result bit is set to 0.
A. 88
B. 59
C. 69
D. 74

Answer: C

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

P a g e 7 | 17
Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value true(or 1) if both
operands are true and return false (or 0) otherwise.
A. 11
B. 25
C. 16
D. 18

Answer: C

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

A. 18
B. 13
C. 22
D. 31

Answer: A

10. What will be the output of the following pseudocode?

Note- ^ is the bitwise exclusive OR operator that compares each bit of its first operand to the
corresponding bit of the one bit is 0 and the other bit is 1, the corresponding result bit is set to 1.
Otherwise, the corresponding result bit is set to 0.
A. 55
B. 40
P a g e 8 | 17
C. 46
D. 43

Answer: D

11. What will be the output of the following pseudocode for a=8, b=1?

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 1.
Otherwise, the corresponding result bit is set to 0.
A. -1
B. 8
C. 2
D. 1

Answer: B

12. What will be the output of the following pseudocode?

Note- ^ is the bitwise exclusive OR operator that compares each bit of the first operand to the
corresponding bit of its second operand. If one bit is 0, the corresponding result bit is set to 1.
Otherwise, the corresponding result bit is set to 0.
A. 59
B. 56
C. 65
D. 53

Answer: A

P a g e 9 | 17
13. What will be the output of the following pseudocode?

Note: countVowel(string) returns the number of vowels in the string, e.g. countVowel(“okay”)
returns 2. lower(string) converts all the letters of the string to lower case, e.g. lower(“OkaY”) returns
“okay”.
A. 12
B. 7
C. 0
D. 4

Answer: D

DATA STRUCTURES

1. 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.
Answer: B

2. If you are using Bubble sort for sorting the given numbers in ascending order, then find out the
number of swapping needed.
12, 16, 10, 7, 13, 3, 9
A. 14
B. 16
C. 12
D. 15
Answer: D

3. Find out the array representation of the given max heap, if the value 25 is inserted in it.
28,17,16,15,14
A. 28,25,17,16,15,14
B. 25,28,17,15,16,14
C. 14,15,16,17,25,28
D. 28,17,25,15,14,16
Answer: D

4. Convert the postfix expression into infix.


ab + cd * f/ -g +
A. (a+b) * (c-d) / (f +g)
B. A+b - (c * d) + (f/g)
P a g e 10 | 17
C. ((a+b) - ((c * d) / f)) + g
D. A + (b-c) / d * (f + g)
Answer: C

5. 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
Answer: C

6. Evaluate the given postfix expression.


23+5*23+4+*
A. 210
B. 225
C. 220
D. 200
Answer: B

7. Evaluate the given postfix expression.


84+423*+2+*
A. 144
B. 128
C. 158
D. 162
Answer: A

8. If you are using bubble sort for sorting the given numbers in ascending order, then find out the
number of swapping needed.
9,23,8,10,32,6,14
A. 9
B. 12
C. 10
D. 11
Answer: C

9. 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

P a g e 11 | 17
D. 21,19,22
Answer: B
10. 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?
1,4,3,5,7,9
A. 5
B. 4
C. 3
D. 2
Answer: A

11. 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
Answer: D

12. Which of the following data structures is non-linear?


A. Stack
B. Array
C. Graph
D. Linked List
Answer: C

13. Find out the array representation of the given min-heap, if the value 110 is inserted in it.
1,2,3,17,19,36,7,25,100
A. 1,3,2,17,19,36,7,110,100,25
B. 1,2,3,17,1,36,9,7,110,100,25
C. 1,2,3,17,19,36,7,25,100,110
D. 1,2,3,17,19,36,7,110,100,25
Answer: C

14. Find out the array representation of the given min heap, if the value 2 is deleted from it.
1,2,3,4
A. 1,4,3
B. 1,3,4
C. 4,3,1
D. 3,4,1
Answer: A

15. Linked lists are used to implement


1. Stack
2. Queue

P a g e 12 | 17
3. Trees

A. 1 and 2
B. All 1, 2, and 3
C. 1 and 3
D. 2 and 3
Answer: B

16. Which of the following statements is/are correct for Double Linked List?
1. All the nodes have two links
2. Provides bidirectional traversing
3. Provides only unidirectional traversing
A. 1 and 3
B. 1 and 2
C. Only 3
D. Only 1
Answer: B

17. If you are using Bubble sort for sorting the given numbers in ascending order, the find out the
number of swapping needed.
2,9,3,6,8,1,5
A. 10
B. 12
C. 11
D. 13
Answer: C

18. Convert the given Prefix expression into infix.


+a - b + * c / d f g
A. (a+b) - (c *d) + f/g
B. A + (b -c/d) * (f + g)
C. A + (b - ((c * (d/f)) + g))
D. A + ( b * c - d) / (f + g)
Answer: C

19. Convert the postfix expression into infix.


A b + c d * f/ -g +
A. A + b - (c * d) + (f/g)
B. A + (b-c) / d *(f + g)
C. (a + b) * (c-d) / (f + g)
D. ((a + b) - ((c * d / f)) + g
Answer: D

P a g e 13 | 17
20. If there is a binary tree of height 8, then what should be the maximum number of nodes in that
tree?
A. 511
B. 255
C. 256
D. 512
Answer: B

21. If the base address of two dimensional array A[80] [20] is 700, then find out the address of an
element a[1][8] in the array.
** Assume 4 words per memory cell and elements are arranged in column major order.
A. 3245
B. 3264
C. 6543
D. 3456
Answer: B

22. If the base address of two dimensional array A[70] [10] is 600, then find out the address of an
element A[2][7] in the array.
** Assume 4 words per memory cell and elements are arranged in column major order.
A. 2658
B. 2543
C. 2568
D. 2345
Answer: C

23. Evaluate the given postfix expression.


10 5 4 2 + 5 * + 3 + *
A. 220
B. 280
C. 320
D. 380
Answer: D

24. How many nodes are present in a strictly binary tree with 8 leaves?
A. 7
B. 15
C. 16
D. 17
Answer: B

25. Find out the maximum number of nodes present in a binary tree of height 5.
A. 16

P a g e 14 | 17
B. 32
C. 15
D. 31
Answer: D

26. If the base address of two dimensional array A[30] [50] is 500, then find out the address of an
element A[5][10] in the array.
** Assume 4 words per memory cell and elements are arranged in row major order.
A. 1189
B. 1124
C. 1160
D. 1540
Answer: D

27. 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?
11, 13, 12, 14, 10, 9
A. 2
B. 5
C. 4
D. 3
Answer: C

28. 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?
12, 13, 16, 10, 9, 7
A. 4
B. 2
C. 5
D. 3
Answer: A

29. Find out the maximum number of nodes present in a tree of height 6.
A. 31
B. 63
C. 64
D. 32
Answer: B

30. Find out the array representation of the given min-heap, if the value 10 is inserted in it.
5, 6, 9, 17, 18
A. 5, 6, 9, 10, 17, 18
B. 5, 6, 9, 17, 18, 10
C. 6, 9, 5, 17, 18, 10

P a g e 15 | 17
D. 9, 5, 6, 17, 18, 10
Answer: B

31. Which of the following is the correct order of the nodes visited during an in-order traversal of the
given noded tree?

A. B-D-A-G-E-C-H-I-G
B. B-D-A-G-E-C-H-F-I
C. D-B-A-G-E-C-H-F-I
D. D-B-A-G-E-C-H-I-F
Answer: B

32. 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.
Answer: A

33. Which of the following is the correct post-order traversal of the given tree?

A. 1 2 4 5 3
B. 4 5 2 3 1
C. 1 2 3 4 5

P a g e 16 | 17
D. 4 2 5 1 3
Answer: B

34. Find out the sum of the degree of vertices in the pseudograph as shown in the image.

A. 12
B. 6
C. 11
D. 8
Answer: C

35. If the base address of two dimensional array A[10] [20] is 100, then find out the address of an
element A[2][6] in the array.
** Assume 4 words per memory cell and elements are arranged in row major order.
A. 286
B. 284
C. 245
D. 278
Answer: B

P a g e 17 | 17
Pseudocode questions

1. WRITE A PSEUDOCODE TO FIND THE LARGEST OF TWO


NUMBERS.
2. BEGIN
3. NUMERIC nNum1,nNum2
4. DISPLAY "ENTER THE FIRST NUMBER :"
5. INPUT nNum1
6. DISPLAY "ENTER THE SECOND NUMBER : "
7. INPUT nNum2
8. IF nNum1 > nNum2
9. DISPLAY nNum1 + " is larger than "+ nNum2
10. ELSE
11. DISPLAY nNum2 + " is larger than " + nNum1
12. END

2. WRITE
A PSEUDOCODE TO FIND THE SUM OF TWO
NUMBERS.
begin

numeric nNum1,nNum2,nSum

display "ENTER THE FIRST NUMBER : "

accept nNum1

display "ENTER THE SECOND NUMBER : "

accept nNum2

compute nSum=nNum1+nNum2

display "SUM OF THESE NUMBER : " nSum

end

3. WRITE A PSEUDOCODE TO FIND THE AREA OF RECTANGLE.


begin

numeric nLen,nBrd,nAre

display "ENTER THE LENGTH OF RECTANGLE : "

accept nLen

display "ENTER THE BREADTH OF RECTANGLE : "

accept nBrd

nAre=nLen*nBrd

display "AREA OF RECTANGLE : " nAre

end
4. WRITE A PSEUDOCODE TO FIND THE AREA OF SQUARE.
begin

numeric nSide, nArea

display "ENTER THE SIDE OF SQUARE : "

accept nSide

nArea=nSide*nSide

display "AREA OF SQUARE : " nArea

end

5. WRITE A PSEUDOCODE TO FIND THE AREA OF CIRCLE.


begin

numeric nRad, nAre

display "ENTER THE RADIUS OF CIRCLE : "

accept nRad

nArea = nRad*nRad*22/7

display "AREA OF CIRCLE : " nArea

end

6. WRITE A PSEUDOCODE TO FIND THE AREA OF


PARALLELOGRAM.
begin

numeric nBase, nPerp, nArea

display "ENTER THE BASE : "

accept nBase

display "ENTER THE PERPENDICULAR : "

accept nPerp

nArea=nBase*nPerp

display "AREA OF PARALLELOGRAM : " nArea

end

7. WRITE A PSEUDOCODE TO FIND THE AREA OF TRIANGLE


begin

numeric nBase, nHigh, nArea

display "ENTER THE BASE OF TRIANGLE : "


accept nBase

display "ENTER THE HEIGHT OF TRIANGLE : "

accept nHigh

nArea=nBase*nHigh

display "AREA OF TRIANGLE : " nArea

end

8. WRITE A PSEUDOCODE TO FIND THE AREA OF RHOMBUS.


begin

numeric nDgn1, nDgn2, nArea

display "ENTER THE LENGTH OF FIRST DIAGONAL : "

accept nDgn1

display "ENTER THE LENGTH OF SECOND DIAGONAL : "

accept nDgn2

nArea=nDgn1*nDgn2/2

display "AREA OF RHOMBUS : " nArea

end

9. WRITE A PSEUDOCODE TO FIND THE GREATEST OF TWO


NUMBERS.
begin

numeric nNum1, nNum2

display "ENTER THE FIRST NUMBER : "

accept nNum1

display "ENTER THE SECOND NUMBER : "

accept nNum2

if(nNum1>nNum2)

begin

display "GREATEST ONE : " nNum1

end

else
begin

display "GREATEST ONE : " nNum2

end

end

10. WRITE A PSEUDOCODE TO FIND THE GREATEST OF TWO


NUMBERS USING TERNARY OPERATOR.
begin

numeric nNum1, nNum2

display "ENTER THE FIRST NUMBER : "

accept nNum1

display "ENTER THE SECOND NUMBER : "

accept nNum2

nGone=(nNum1>nNum2)?nNum1:nNum2

display "GREATEST ONE : " nGone

end

11. WRITE A PSEUDOCODE TO FIND THE GREATEST OF THREE


NUMBERS.
begin

numeric nNum1,nNum2,nNum3

display "ENTER THE FIRST NUMBER : "

accept nNum1

display "ENTER THE SECOND NUMBER : "

accept nNum2

display "ENTER THE THIRD NUMBER : "

accept nNum3

if(nNum1>nNum2)

begin

if(nNum1>nNum3)

begin

display "GREATEST ONE : " nNum1

end

else
begin

display "GREATEST ONE : " nNum3

end

end

else

if(nNum2>nNum3)

begin

display "GREATEST ONE : " nNum2

end

else

begin

display "GREATEST ONE : " nNum3

end
Capgemini Questions with Answers
Pseudocode Questions and Answers

ALGORITHMS
1. What will be the output of the following pseudo code?

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 1.
Otherwise, the corresponding result bit is set to 0.
A. 6
B. 24
C. 7
D. 11

Answer: C

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

A. 22
B. 18
C. 31
D. 13

Answer: B

P a g e 5 | 17
3. What will be the output of the following pseudocode?

Note: reverse(string) reverses the string, e.g. reverse(‘okay’) returns ‘Yako’.


countConso(string) returns the number of consonants in the string, e.g. countConso(“okay”) returns
2. upper(string) converts all the letters of the string to upper case, e.g. upper(“Okay”) returns “OKAY”.
A. 5
B. 10
C. 7
D. 4

Answer: A

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

A. 96
B. 15
C. 33
D. 26

Answer: B

5. What will be the output of the following pseudocode for a=2, b=7, c=7?

A. 26
B. 14
C. 16
D. 18

Answer: C

6. What will be the output of the following pseudocode for p=7, q=2?

P a g e 6 | 17
A. 20
B. 2
C. 12
D. 3

Answer: D

7. What will be the output of the following pseudocode?

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 1.
Otherwise, the corresponding result bit is set to 0.
A. 88
B. 59
C. 69
D. 74

Answer: C

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

P a g e 7 | 17
Note- &&: Logical AND - The logical AND operator (&&) returns the Boolean value true(or 1) if both
operands are true and return false (or 0) otherwise.
A. 11
B. 25
C. 16
D. 18

Answer: C

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

A. 18
B. 13
C. 22
D. 31

Answer: A

10. What will be the output of the following pseudocode?

Note- ^ is the bitwise exclusive OR operator that compares each bit of its first operand to the
corresponding bit of the one bit is 0 and the other bit is 1, the corresponding result bit is set to 1.
Otherwise, the corresponding result bit is set to 0.
A. 55
B. 40
P a g e 8 | 17
C. 46
D. 43

Answer: D

11. What will be the output of the following pseudocode for a=8, b=1?

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 1.
Otherwise, the corresponding result bit is set to 0.
A. -1
B. 8
C. 2
D. 1

Answer: B

12. What will be the output of the following pseudocode?

Note- ^ is the bitwise exclusive OR operator that compares each bit of the first operand to the
corresponding bit of its second operand. If one bit is 0, the corresponding result bit is set to 1.
Otherwise, the corresponding result bit is set to 0.
A. 59
B. 56
C. 65
D. 53

Answer: A

P a g e 9 | 17
13. What will be the output of the following pseudocode?

Note: countVowel(string) returns the number of vowels in the string, e.g. countVowel(“okay”)
returns 2. lower(string) converts all the letters of the string to lower case, e.g. lower(“OkaY”) returns
“okay”.
A. 12
B. 7
C. 0
D. 4

Answer: D

DATA STRUCTURES

1. 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.
Answer: B

2. If you are using Bubble sort for sorting the given numbers in ascending order, then find out the
number of swapping needed.
12, 16, 10, 7, 13, 3, 9
A. 14
B. 16
C. 12
D. 15
Answer: D

3. Find out the array representation of the given max heap, if the value 25 is inserted in it.
28,17,16,15,14
A. 28,25,17,16,15,14
B. 25,28,17,15,16,14
C. 14,15,16,17,25,28
D. 28,17,25,15,14,16
Answer: D

4. Convert the postfix expression into infix.


ab + cd * f/ -g +
A. (a+b) * (c-d) / (f +g)
B. A+b - (c * d) + (f/g)
P a g e 10 | 17
C. ((a+b) - ((c * d) / f)) + g
D. A + (b-c) / d * (f + g)
Answer: C

5. 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
Answer: C

6. Evaluate the given postfix expression.


23+5*23+4+*
A. 210
B. 225
C. 220
D. 200
Answer: B

7. Evaluate the given postfix expression.


84+423*+2+*
A. 144
B. 128
C. 158
D. 162
Answer: A

8. If you are using bubble sort for sorting the given numbers in ascending order, then find out the
number of swapping needed.
9,23,8,10,32,6,14
A. 9
B. 12
C. 10
D. 11
Answer: C

9. 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

P a g e 11 | 17
D. 21,19,22
Answer: B
10. 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?
1,4,3,5,7,9
A. 5
B. 4
C. 3
D. 2
Answer: A

11. 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
Answer: D

12. Which of the following data structures is non-linear?


A. Stack
B. Array
C. Graph
D. Linked List
Answer: C

13. Find out the array representation of the given min-heap, if the value 110 is inserted in it.
1,2,3,17,19,36,7,25,100
A. 1,3,2,17,19,36,7,110,100,25
B. 1,2,3,17,1,36,9,7,110,100,25
C. 1,2,3,17,19,36,7,25,100,110
D. 1,2,3,17,19,36,7,110,100,25
Answer: C

14. Find out the array representation of the given min heap, if the value 2 is deleted from it.
1,2,3,4
A. 1,4,3
B. 1,3,4
C. 4,3,1
D. 3,4,1
Answer: A

15. Linked lists are used to implement


1. Stack
2. Queue

P a g e 12 | 17
3. Trees

A. 1 and 2
B. All 1, 2, and 3
C. 1 and 3
D. 2 and 3
Answer: B

16. Which of the following statements is/are correct for Double Linked List?
1. All the nodes have two links
2. Provides bidirectional traversing
3. Provides only unidirectional traversing
A. 1 and 3
B. 1 and 2
C. Only 3
D. Only 1
Answer: B

17. If you are using Bubble sort for sorting the given numbers in ascending order, the find out the
number of swapping needed.
2,9,3,6,8,1,5
A. 10
B. 12
C. 11
D. 13
Answer: C

18. Convert the given Prefix expression into infix.


+a - b + * c / d f g
A. (a+b) - (c *d) + f/g
B. A + (b -c/d) * (f + g)
C. A + (b - ((c * (d/f)) + g))
D. A + ( b * c - d) / (f + g)
Answer: C

19. Convert the postfix expression into infix.


A b + c d * f/ -g +
A. A + b - (c * d) + (f/g)
B. A + (b-c) / d *(f + g)
C. (a + b) * (c-d) / (f + g)
D. ((a + b) - ((c * d / f)) + g
Answer: D

P a g e 13 | 17
20. If there is a binary tree of height 8, then what should be the maximum number of nodes in that
tree?
A. 511
B. 255
C. 256
D. 512
Answer: B

21. If the base address of two dimensional array A[80] [20] is 700, then find out the address of an
element a[1][8] in the array.
** Assume 4 words per memory cell and elements are arranged in column major order.
A. 3245
B. 3264
C. 6543
D. 3456
Answer: B

22. If the base address of two dimensional array A[70] [10] is 600, then find out the address of an
element A[2][7] in the array.
** Assume 4 words per memory cell and elements are arranged in column major order.
A. 2658
B. 2543
C. 2568
D. 2345
Answer: C

23. Evaluate the given postfix expression.


10 5 4 2 + 5 * + 3 + *
A. 220
B. 280
C. 320
D. 380
Answer: D

24. How many nodes are present in a strictly binary tree with 8 leaves?
A. 7
B. 15
C. 16
D. 17
Answer: B

25. Find out the maximum number of nodes present in a binary tree of height 5.
A. 16

P a g e 14 | 17
B. 32
C. 15
D. 31
Answer: D

26. If the base address of two dimensional array A[30] [50] is 500, then find out the address of an
element A[5][10] in the array.
** Assume 4 words per memory cell and elements are arranged in row major order.
A. 1189
B. 1124
C. 1160
D. 1540
Answer: D

27. 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?
11, 13, 12, 14, 10, 9
A. 2
B. 5
C. 4
D. 3
Answer: C

28. 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?
12, 13, 16, 10, 9, 7
A. 4
B. 2
C. 5
D. 3
Answer: A

29. Find out the maximum number of nodes present in a tree of height 6.
A. 31
B. 63
C. 64
D. 32
Answer: B

30. Find out the array representation of the given min-heap, if the value 10 is inserted in it.
5, 6, 9, 17, 18
A. 5, 6, 9, 10, 17, 18
B. 5, 6, 9, 17, 18, 10
C. 6, 9, 5, 17, 18, 10

P a g e 15 | 17
D. 9, 5, 6, 17, 18, 10
Answer: B

31. Which of the following is the correct order of the nodes visited during an in-order traversal of the
given noded tree?

A. B-D-A-G-E-C-H-I-G
B. B-D-A-G-E-C-H-F-I
C. D-B-A-G-E-C-H-F-I
D. D-B-A-G-E-C-H-I-F
Answer: B

32. 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.
Answer: A

33. Which of the following is the correct post-order traversal of the given tree?

A. 1 2 4 5 3
B. 4 5 2 3 1
C. 1 2 3 4 5

P a g e 16 | 17
D. 4 2 5 1 3
Answer: B

34. Find out the sum of the degree of vertices in the pseudograph as shown in the image.

A. 12
B. 6
C. 11
D. 8
Answer: C

35. If the base address of two dimensional array A[10] [20] is 100, then find out the address of an
element A[2][6] in the array.
** Assume 4 words per memory cell and elements are arranged in row major order.
A. 286
B. 284
C. 245
D. 278
Answer: B

P a g e 17 | 17

You might also like