Pseudocode Quiz 1

Question 1

Time: 00:00:00
Consider the below code and choose line can be replaced by which one of the following : 

int sum (int A[], int n)

{

   int sum = 0, i;

   for (i = 0; i < n; i++) ------- line 1

     sum = sum + A[i];

  return sum;

}

for ( i = 0 ; i > n ; i++ )

for ( i = 0 ; i > n ; i++ )

for ( int i = 0 ; i < n ; i++ )

for ( int i = 0 ; i < n ; i++ )

for ( i = 0 ; i < n ; ++i )

for ( i = 0 ; i < n ; ++i )

for ( i = 0 ; i > n ; )

for ( i = 0 ; i > n ; )

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
What will be the output of the following pseudo code?
function (input a, input b)
if (a > b)
return function (b, a)
elseif (b != 0)
return (a + function (a, b - 1))
else
return 0

function(6,8)

48

48

50

50

52

52

68

68

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What will be the output of the following pseudo code?

Input m = 12, n = 4
m = m - 1 ;
n = n + 1 ;
m = m + n ;
n = n - 1 ;
Print m,n

16,4

16,4

15,4

15,4

4,16

4,16

17,4

17,4

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What will be the output of the following pseudo-code?

Input i=8,j=9
Function ( i , j )
for x=1 to x=5
If i < j
i++
Else
j++
print( i, j )

10,11

10,11

11,10

11,10

11,11

11,11

10,10

10,10

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What will be the time complexity of the following pseudo code?

Input i=8,j=9
Function ( i , j )
for x=1 to x=5
If i < j
i++
Else
j++
print( i, j )

O(x)

O(x)

O(1)

O(1)

O(logx)

O(logx)

O(x^2)

O(x^2)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
What will be the output of the following pseudo code?

function(int n)
if (n <= 1)
return n
return function(n-1) + function(n-2)
End of function

main ()
int n = 9
printf("%d", function(n))
return 0
End of main

32

32

34

34

30

30

28

28

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
What will be the time complexity of the following pseudo code?

function (int n)
{
int a = 0, b = 1, c, i;
if( n == 0)
return a;
for (i = 2; i <= n; i++)
{
c = a + b;
a = b;
b = c;
}
return b;
}

int main ()
{
int n = 9;
printf("%d", function(n));
return 0;
}

O(log(n))

O(log(n))

O(n)

O(n)

O(n^2)

O(n^2)

O(1)

O(1)

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
What does the following piece of code do?

public void func (Tree root)
{
func (root.left ());
func (root.right ());
System.out.println (root.data ());
}

Pre-order

Pre-order

In-order

In-order

Level-order

Level-order

Post-order

Post-order

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
How will you find the pre order traversal of a tree?

public void func (Tree root) { func (root.left ()); func (root.right ()); System.out.println (root.data ()); }

public void func (Tree root) { func (root.left ()); func (root.right ()); System.out.println (root.data ()); }

public void func (Tree root) { System.out.println (root.data ()); func (root.left ()); func (root.right ()); }

public void func (Tree root) { System.out.println (root.data ()); func (root.left ()); func (root.right ()); }

public void func (Tree root) { func (root.left ()); System.out.println (root.data ()); func (root.right ()); }

public void func (Tree root) { func (root.left ()); System.out.println (root.data ()); func (root.right ()); }

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
What will be the output of the following pseudo code ?

initialize char c
set c = ‘f’
print "%d",c

102

102

99

99

67

67

70

70

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/0

Accuracy

0%