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 ; )

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

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

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

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)

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

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)

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

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

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

null
null

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%

Get over 200+ Courses under One Subscription

mute

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assistance

Get Access to PrepInsta Prime

Top Faculty

from FAANG/IITs/TOP MNC's

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.