• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

SP Contest 1

Question 1

How many times is the below loop executed? C
 for(int i=0; i < n; i++)
 {
    for(int j=0; j < (2*i); j+=(i/2))
    {
	cout<<\"Hello Geeks\";
    }
 }
  • O(n)
  • Infinite times
  • O(n2)
  • O(nlogn)

Question 2

The Postorder traversal of a Binary Search Tree is {35, 30, 45, 40, 70, 85, 90, 80, 50}. What is its Preorder traversal?
  • 50, 40, 30, 35, 45, 80, 70, 90, 85
  • 50, 40, 45, 30, 35 ,80 , 90, 85, 70
  • 50, 80, 90, 85, 70, 40, 45, 30, 35
  • 30, 35, 40, 45, 50, 70, 80, 85, 90

Question 3

Which statement is true about initializing a variable to a default value (i.e. integer to 0, boolean to false) using the default constructor?
  • It initializes the data member variables to default values in C++ but not in JAVA.
  • It initializes the data member variables to default values neither in C++ nor in JAVA.
  • It initializes the data member variables to default values in C++ and JAVA both.
  • It initializes the data member variables to default values in JAVA but not in C++.

Question 4

Below are some operators separated by comma in C++. Which of these operators cannot be overloaded?
!, ::, ->*, ~, .*, sizeof, new
  • ->*, .*, sizeof
  • .*, ~, new
  • ::, sizeof, !
  • sizeof, .*, ::

Question 5

What is the output of below C program?
C
#include <stdio.h>

void print(int c){
    
    if (c < 0) {
        return;
    }
    
    printf(\"%d \", c);
    c--;
    print(c);
    
    c++;
    
    printf(\"%d \", c);

}

int main() {
   int c = 5;
   print(c);
   return 0;	
} 
  • 5 4 3 2 1 0 0 0 1 2 3 4
  • 5 4 3 2 1 0 0 1 2 3 4 5
  • 1 2 3 4 5 0 0 5 4 3 2 1
  • 5 4 3 2 1 1 0 1 2 3 4 5

Question 6

A can finish an IT project in 15 days, B can finish the same project in 12 days. In how many days, both of them can finish 60% of the project? It may be assumed that working together does not impact their productivity.
  • 2 days
  • 4 days
  • 6 days
  • 7 days

Question 7

How many numbers of 6 digits are possible with the property that the sum of their digits is 5?
  • 96
  • 104
  • 120
  • 126

Question 8

Find the missing term in the below sequence:
1, 1, 4, 25, 196, __ , 17424 
  • 1561
  • 1764
  • 1600
  • None of these

Question 9

Here are the two concurrent process A, B with respective codes: Code A:
while (true) // infinite condition
{
    M :____;
    printf("%c", b);
    printf("%c", b);
    N:____;
}
Code B:
while (true) // infinite condition
{
    O:____;
    printf("%c", a);
    printf("%c", a);
    P:____;
}
What should be the binary semaphore operation on M, N, O, P respectively and what must be the initial values of semaphore X, Y in order to get the output bbaabbaabbaa . . . ? Where P is down and V is up operation respectively.
  • M = P(Y), N = V(X), O = P(X), P = V(Y); X = 0, Y = 1;
  • M = P(Y), N = V(X), O = P(X), P = P(Y); X = Y = 1;
  • M = P(Y), N = V(Y), O = P(X), P = V(X); X = 1, Y = 0;
  • M = P(Y), N = V(Y), O = P(X), P = V(X); X = Y = 1;

There are 9 questions to complete.

Last Updated :
Take a part in the ongoing discussion