10/13/2014 |
tech.htm |
Ques 1 : Choose the correct answer
There is a new
Option 1 : 4 |
Option 2 : 5 |
Option 3 : 1 |
Option 4 : 3 |
|
|
|
|
|
|
|
|
Ques 2 : Choose the correct answer
A data type is stored as an 6 bit signed integer. Which of the following cannot be represented by this data type?
Option 1 : |
Option 2 : 0 |
Option 3 : 32 |
Option 4 : 18 |
|
|
|
|
|
|
|
|
Ques 3 : Choose the correct answer
A language has 28 different letters in total. Each word in the language is composed of maximum 7 letters. You want to create a
Option 1 : 7 |
Option 2 : 35 |
Option 3 |
: 28 |
Option 4 : 196 |
|
|
|
|
|
||
|
|
|
|
||
Ques 4 : Choose the correct answer |
|
|
|
||
A |
|
|
|||
Option 1 : 0 to 1000 |
Option 2 : 0 to 1024 |
Option 3 |
: 1 to 1025 |
Option 4 : 0 to |
|
1023 |
|||||
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
Ques 5 : Choose the correct answer
Rajni wants to create a
Option 1 : 52 |
Option 2 : 127 |
Option 3 : 53 |
Option 4 : 75 |
|
|
|
|
|
|
|
|
Ques 6 : Choose the correct answer
A new language has 15 possible letters, 8 different kinds of punctuation marks and a blank character. Rahul wants to create two data types, first one which could store the letters of the language and a second one which could store any character in the language. The number of bits required to store these two
Option 1 : 3 and 4 |
Option 2 : 4 and 3 |
Option 3 : 4 and 5 |
Option 4 : 3 and 5 |
|
|
|
|
|
|
|
|
Ques 7 : Choose the correct answer
Parul takes as input two numbers: a and b. a and b can take integer values between 0 and 255. She stores a, b and c as
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
1/41 |
10/13/2014 |
tech.htm |
c = a + 2*b
To her surprise her program gives the right output with some input values of a and b, while gives an erroneous answer for others. For which of the following inputs will it give a wrong answer?
Option 1 : a = 10 b = |
Option 2 : a = 200 b = |
Option 3 : a = 50 b = 100 |
Option 4 : a = 100 |
200 |
10 |
b = 50 |
|
|
|
|
|
|
|
|
|
Ques 8 : Choose the correct answer
Prashant takes as input 2 integer numbers, a and b, whose value can be between 0 and 127. He stores them as 7 bit numbers. He writes the following code to process these numbers to produce a third number c.
c = a - b
In how many minimum bits should Prashant store c?
Option 1 : 6 bits |
Option 2 : 7 bits |
Option 3 : 8 bits |
Option 4 : 9 bits |
|
|
|
|
|
|
|
|
Ques 9 : Choose the correct answer
Ankita takes as input 2 integer numbers, a and b, whose value can be between 0 and 31. He stores them as 5 bit numbers. He writes the following code to process these numbers to produce a third number c.
c = 2*(a - b)
In how many minimum bits should Ankita store c?
Option 1 : 6 bits |
Option 2 : 7 bits |
Option 3 : 8 bits |
Option 4 : 9 bits |
|
|
|
|
|
|
|
|
Ques 10 : Choose the correct answer
A character in new programming language is stored in 2 bytes. A string is represented as an array of characters. A word is stored as a string. Each byte in the memory has an address. The word "Mahatma Gandhi" is stored in the memory with starting address 456. The letter 'd' will be at which memory address?
Option 1 : 468 |
Option 2 : 480 |
Option 3 : 478 |
Option 4 : 467 |
|
|
|
|
|
|
|
|
Ques 11 : Choose the correct answer
Stuti is making a questionnaire of
Option 1 : integer |
Option 2 : boolean |
Option 3 : float |
Option 4 : |
character |
Ques 12 : Choose the correct answer:
A
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
2/41 |
10/13/2014 |
tech.htm |
accommodate any number. If two different
What will be the output of the following |
|
||
integer a = 456, |
b, c, d =10 |
|
|
b = a/d |
|
|
|
c = a - b |
|
|
|
print c |
|
|
|
Option 1 : 410 |
Option 2 : 410.4 |
Option 3 : 411.4 |
Option 4 : 411 |
|
|
|
|
|
|
|
|
Ques 13 : Choose the correct answer:
A
// in pseudo code refers to comment
What will be the output of the following |
|
||
integer a = 984, |
b, c, d =10 |
|
|
print remainder(a,d) // remainder when a is divided by d |
|
||
a = a/d |
|
|
|
print remainder(a,d) // remainder when a is divided by d |
|
||
Option 1 : 48 |
Option 2 : Error |
Option 3 : 84 |
Option 4 : 44 |
|
|
|
|
|
|
|
|
Ques 14 : Choose the correct answer:
Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.) * / + - AND OR
For operators with equal precedence, the precedence is from
What will be the output of the following code statements?
integer a = 50, b = 25, c = 0
print ( a > 45 OR b > 50 AND c > 10 )
Option 1 : 1 |
Option 2 : 0 |
Option 3 : |
Option 4 : 10 |
|
|
|
|
|
|
|
|
Ques 15 : Choose the correct answer:
Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.) * / + - AND OR
For operators with equal precedence, the precedence is from
What will be the output of the following code statements?
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
3/41 |
10/13/2014 |
|
tech.htm |
|
|
|
integer a = 50, b = 25, c = 5 |
|
|
|
|
print a * b / c + c |
|
|
|
|
Option 1 : 120 |
Option 2 : 125 |
Option 3 : 255 |
Option 4 : 250 |
|
|
|
|
|
|
|
|
|
|
Ques 16 : Choose the correct answer:
Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.) * / + - AND OR
For operators with equal precedence, the precedence is from
What will be the output of the following code statements?
integer a = 10, b = 35, c = 5 print a * b / c - c
Option 1 : 65 |
Option 2 : 60 |
Option 3 : Error |
Option 4 : 70 |
|
|
|
|
|
|
|
|
Ques 17 : Choose the correct answer:
Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.) * / + - AND OR
For operators with equal precedence, the precedence is from
integer a = 10, b = 35, c = 5
Comment about the output of the two statements? print a * b + c / d
print c / d + a * b
Option 1 : Differ due
to
Ques 18 : Choose the correct answer:
Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.) * / + - AND OR
For operators with equal precedence, the precedence is from
integer a = 40, b = 35, c = 20, d = 10
Comment about the output of the following two statements:
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
4/41 |
10/13/2014 |
tech.htm |
|
|
|
print a * b / c - d |
|
|
|
print a * b / (c - d) |
|
|
|
Option 1 : Differ by 80 Option 2 : Same |
Option 3 : Differ by 50 |
Option 4 : Differ |
|
by 160 |
||
|
|
|
|
|
|
|
|
Ques 19 : Choose the correct answer:
Assume the following precedence (high to low). Operators in the same row have the same precedence:
(.) * / + - AND OR
For operators with equal precedence, the precedence is from
What will be the output of the following two statements: print ( a > 45 OR b > 50 AND c > 10 )
print ( ( a > 45 OR b > 50 ) AND c > 10 )
Option 1 : 0 and 1 |
Option 2 : 0 and 0 |
Option 3 : 1 and 1 |
Option 4 : 1 and 0 |
|
|
|
|
|
|
|
|
Ques 20 : Choose the correct answer:
A
// in pseudo code refers to comment
What will be the output of the following |
|
||
integer a = 984, |
b=10 |
|
|
//float is a |
|
|
|
float c |
|
|
|
c = a / b |
|
|
|
print c |
|
|
|
Option 1 : 984 |
Option 2 : 98.4 |
Option 3 : 98 |
Option 4 : Error |
|
|
|
|
|
|
|
|
Ques 21 : Choose the correct answer:
A
// in pseudo code refers to comment
What will be the output of the following
//float is a
c = a / b print c
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
5/41 |
10/13/2014 |
|
tech.htm |
|
|
|
Option 1 : 984 |
Option 2 : Error |
Option 3 : 98.4 |
Option 4 : 98 |
|
|
|
|
|
|
|
|
|
|
Ques 22 : Choose the correct answer
Smriti wants to make a program to print the sum of square of the first 5 whole numbers (0...4). She writes the following program:
integer i = 0 // statement 1 integer sum = 0 // statement 2 while ( i < 5 ) // statement 3
{
sum = i*i // statement 4 i = i + 1 // statement 5
}
print sum // statement 6
Is her program correct? If not, which statement will you modify to correct it?
Option 1 : No error, |
Option 2 : Statement 1 Option 3 : Statement 4 |
Option 4 : |
the program is correct. |
statement 6 |
|
|
|
|
|
|
|
Ques 23 : Choose the correct answer
Shashi wants to make a program to print the sum of the first 10 multiples of 5. She writes the following program, where statement 5 is missing:
integer i = 0 integer sum = 0 while ( i <= 50 )
{
sum = sum + i
}
print sum
Which of the following will you use for statement 5?
Option 1 : i = 5 |
Option 2 : i = 5 * i |
Option 3 : i = i + 1 |
Option 4 : i = i + 5 |
|
|
|
|
|
|
|
|
Ques 24 : Choose the correct answer
Shantanu wants to make a program to print the sum of the first 7 multiples of 6. He writes the following program:
integer i = 0 // statement 1 integer sum // statement 2 while ( i <= 42 ) // statement 3
{
sum = sum + i // statement 4 i = i + 6;
}
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
6/41 |
10/13/2014 |
tech.htm |
print sum // statement 6
Does this program have an error? If yes, which one statement will you modify to correct the program?
Option 1 : Statement 1 Option 2 : Statement 2 Option 3 : Statement 3 |
Option 4 : |
Statement 4 |
|
|
|
|
|
Ques 25 : Choose the correct answer
Sharmili wants to make a program to print the sum of all perfect cubes, where the value of the cubes go from 0 to 100. She writes the following program:
integer i = 0, a // statement 1 integer sum = 0;
a = ( i * i * i )
while ( i < 100 ) // statement 2
{
sum = sum + a // statement 3 i = i + 1
a = ( i * i * i ) // statement 4
}
print sum
Does this program have an error? If yes, which one statement will you modify to correct the program?
|
Option 4 : |
Option 5 |
|
Option 1 : Statement 1 Option 2 : Statement 2 Option 3 : Statement 3 |
: No |
||
Statement 4 |
|||
|
|
error |
|
|
|
|
|
|
|
|
Ques 26 : Choose the correct answer
Bhavya wants to make a program to print the sum of all perfect squares, where the value of the squares go from 0 to 50. She writes the following program:
integer i = 1, a // statement 1 integer sum = 0
while ( a < 50 ) // statement 2
{
sum = sum + a // statement 3 i = i + 1
a = ( i * i ); // statement 4
}
print sum
Does this program have an error? If yes, which one statement will you modify to correct the program?
|
Option 4 : |
Option 5 |
|
Option 1 : Statement 1 Option 2 : Statement 2 Option 3 : Statement 3 |
: No |
||
Statement 4 |
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
7/41 |
10/13/2014 |
tech.htm |
error
Ques 27 : Choose the correct answer
Vijay wants to print the following pattern on the screen: 2
24
24 6
24 6 8
He writes the following program:
integer i = 1, j=2 // statement 1 while ( i <= 4 ) // statement 2
{
j = 2;
while ( j <= ? ) // Statement 3
{
print j
print blank space j = j + 2
}
print
}
What is the value of ? in statement 3 ::
Option 1 : 8 |
Option 2 : i |
Option 3 : 2*i |
Option 4 : 4 |
|
|
|
|
|
|
|
|
Ques 28 : Choose the correct answer
Shravanti writes the following program:
integer i = 0, j while ( i < 2 )
{
j = 0;
while ( j <= 3*i )
{
print j
print blank space j = j + 3
}
print
}
What will be the output of the program?
Option 1 : 0 |
Option 2 : 0 3 |
Option 3 : 0 |
Option 4 : 0 3 6 |
|
|
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
8/41 |
10/13/2014 |
|
tech.htm |
|
|
0 3 |
0 3 6 |
0 3 6 |
0 3 6 9 |
|
|
|
|
0 3 6 9 |
0 3 6 9 12 |
|
|
|
|
|
|
|
|
|
|
Ques 29 : Choose the correct answer
Vijay wants to print the following pattern on the screen: 1
12
12 3
He writes the following program:
integer i = 1 // statement 1 while ( i <= 3 )
{
int j // Statement 2
while ( j <= i ) // Statement 3
{
print j
print blank space
j = j + 1 // Statement 4
}
print
}
Will this program function correctly? If not which one statement will you modify to make the program function correctly?
|
|
Option 5 |
|
|
: |
Option 1 : Statement 1 Option 2 : Statement 2 Option 3 : Statement 3 |
Option 4 : |
Program |
Statement 4 |
does not |
|
|
|
have |
|
|
error. |
|
|
|
|
|
|
Ques 30 : Choose the correct answer |
|
|
Charu writes the following program: |
|
|
integer i = 1, j, a |
|
|
while ( i <= 4 ) |
|
|
{ |
|
|
j = 1; |
|
|
a = 0; |
|
|
while ( a <= 5*i ) |
|
|
{ |
|
|
a = 2^j; |
|
|
print a |
|
|
print blank space |
|
|
j = j + 1 |
|
|
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
9/41 |
10/13/2014 |
|
tech.htm |
|
|
} |
|
|
|
|
|
print |
|
||
|
i = i + 1 |
|
|
|
} |
|
|
|
|
|
What will be the output of the program? |
|
|
|
|
Option 1 : 2 |
Option 2 : 2 4 |
Option 3 : 2 4 |
Option 4 : 2 |
2 4 |
2 4 8 |
2 4 8 |
2 4 |
|
2 4 8 |
2 4 8 16 |
2 4 8 |
2 4 |
|
2 4 8 16 |
2 4 8 16 32 |
2 4 8 16 |
2 4 8 16 |
|
|
|
|
|
|
|
|
|
|
|
Ques 31 : Choose the correct answer
Himanshu wants to write a program to print the larger of the two inputted number. He writes the following code:
int number1, number 2 input number1, number 2 if ("??") // Statement 1 print number1
else
print number2 end if
Fill in the ?? in statement 1.
Option 1 : |
Option 2 : |
Option 3 : number2 |
Option 4 : |
|
number1 <= |
||||
number1>number2 |
number2>number1 |
equals number1 |
||
number2 |
||||
|
|
|
||
|
|
|
|
|
|
|
|
|
Ques 32 : Choose the correct answer
Shalini wants to program to print the largest number out of three inputted numbers. She writes the following program:
int number1, number 2, number3, temp; input number1, number2, number3;
if (number1>number2) temp = number1
else
temp = number2 end if
if (??) // Statement 1 temp = number3 end if
print temp
Fill in the ?? in Statement 1 |
|
|
||
Option 1 : number3 > |
Option 2 : number3 > |
Option 3 : number3 < |
Option 4 : |
|
number3 > |
||||
number2 |
temp |
temp |
||
number1 |
||||
|
|
|
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
10/41 |
10/13/2014 |
tech.htm |
Ques 33 : Choose the correct answer
Rohit writes the following program which inputs a number and prints "Double digit" if the number is composed of two digits and "Not a double digit" if it is not.
int number;
if (number>10 AND number < 100) print "Double digit"
else
print "Not a double digit" end if
Rohit tries the following inputs: 5 and 66. The program works fine. He asks his brother Ravi to try the program. When Ravi enters a number, the program doesn't work correctly. What did Ravi enter?
Option 1 : 8 |
Option 2 : 100 |
Option 3 : 99 |
Option 4 : 10 |
|
|
|
|
|
|
|
|
Ques 34 : Choose the correct answer
Rohan writes the following program which inputs a number and prints "Triple digit" if the number is composed of three digits and "Not triple digit" if it is not.
int number; if (number>99)
print "Triple digit" else
print "Not triple digit" end if
Rohan tries the following inputs: 25 and 566. The program works fine. He asks his brother Ravi to try the program. When Ravi enters a number, the program doesn't work correctly. What did Ravi enter?
Option 1 : 99 |
Option 2 : 100 |
Option 3 : 0 |
Option 4 : 1000 |
|
|
|
|
|
|
|
|
Ques 35 : Choose the correct answer
Abhinav wants to find the largest number in a given list of 20 numbers. Which of the following is an efficient approach to do this?
Option 1 : Use bubble sort to sort the list in descending order and then print the first number of the series.
Option 2 : Use Option 3 : Implement one selection sort to sort the iteration of selection sort
list in descending order |
for descending order and |
and then print the first |
print the first number in |
number of the series. |
the series. |
Option 4 : None of these
Ques 36 : Choose the correct answer
Lavanya wants to find the smallest number out of 26 inputted numbers. How many minimum comparisons he has to make?
Option 1 : 25 |
Option 2 : 13 |
Option 3 : 26 |
Option 4 : 52 |
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
11/41 |
10/13/2014 |
tech.htm |
|
|
|
|
|
|
|
Ques 37 : Choose the correct answer
A company offers commission for selling it products to its salesperson. The commission rate is Rs. 5 per product. However if the salesperson sells more than 200 items, he gets a commission of Rs. 10 on all items he sold after the first 200. Kanu writes a program to calculate the commission for the salesperson:
integer numberProducts, commission input numberProducts
if ( numberProducts > 200 )
commission = numberProducts * 5 end if
print commission
Fill in the missing statement.
Option 1 : commission |
Option 2 : commission |
|
|
= 200 * 5 + |
Option 3 : commission = |
Option 4 : None of |
|
= (numberProducts - |
(numberProducts - 200) numberProducts * 10 |
these |
|
200) * 10 |
* 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ques 38 : Choose the correct answer
Vikram wants to write a program which checks whether the inputted number is divisible by any of the first 6 natural numbers (excluding 1). He writes the following efficient code for it.
int number, n = 2, isdivisible=0 input number
while ( n <=6) // Statement 1
{
if ( remainder (number, n) == 0) isdivisible = 1
end
n = n+1 // Statement 2
}
if (isdivisible equals 1) print "It is divisible" else
print "It is not divisible" end
Vikram takes the program to Hari. Hari tells Vikram that though the code is correct, it can be made more efficient. Hari modifies a single statement and makes the code more efficient. Which statement does he modify and how?
Option 1 : Statement 1 |
Option 2 : Statement 1 |
Option 3 : Statement 1 is |
Option 4 : |
|
is changed to: |
is changed to: |
Statement 2 is |
||
while (n <=6 AND |
while (n <=6 OR |
changed to: |
changed to: |
|
while (isdivisible=0) |
||||
|
|
|
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
12/41 |
10/13/2014 |
|
tech.htm |
|
|
isdivisible=0) |
isdivisible=0) |
n = n + 2 |
|
|
|
|
|
|
|
|
Ques 39 : Choose the correct answer
Rajiv wants to make a program which inputs two numbers: a and b (a>b) and computes the number of terms between a and b (including a and b). What will be code statement to do this:
Option 1 : a - b Option 2 : a - b + 1 Option 3 : a + b Option 4 : a - b - 1
Ques 40 : Choose the correct answer
I have a problem to solve which takes as input a number n. The problem has a property that given the solution for
Option 1 : Iteration |
Option 2 : Decision- |
Option 3 : Object |
Option 4 : |
|
making |
Oriented Programming |
Recursion |
||
|
||||
|
|
|
|
|
|
|
|
|
Ques 41 : Choose the correct answer:
A
"pointer" is a
Statement "*b = a" puts the value a at the memory address referenced by b.
What is the output of the following code statements? The compiler saves the first integer at the memory location 4062. Integer is one byte long.
integer a pointer b a = 20 b = &a print *b
Option 1 : 4062 Option 2 : 4063 Option 3 : 20 Option 4 : 10
Ques 42 : Choose the correct answer:
A
"pointer" is a
Statement "*b = a" puts the value a at the memory address referenced by b.
What is the output of the following code statements? The compiler saves the first integer at the memory location 4165 and the rest at consecutive memory spaces in order of declaration. Integer is one byte long.
integer a, b pointer c, d a = 30
c = &a b = *c
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
13/41 |
10/13/2014 |
|
tech.htm |
|
|
|
a = a + 10 |
|
|
|
|
print b |
|
|
|
|
Option 1 : 30 |
Option 2 : 4165 |
Option 3 : 40 |
Option 4 : 4166 |
|
|
|
|
|
|
|
|
|
|
Ques 43 : Choose the correct answer:
A
"pointer" is a
Statement "*b = a" puts the value a at the memory address referenced by b.
What is the output of the following code statements? The compiler saves the first integer at the memory location 4165 and the rest at consecutive memory spaces in order of declaration. Integer is one byte long.
integer a pointer c, d a = 30
c = &a d = c
a = a + 10 print *c
Option 1 : 30 Option 2 : 4165 Option 3 : 40 Option 4 : 4166
Ques 44 : Choose the correct answer
What is space complexity of a program?
Option 1 : Amount of
Option 2 : Amount of
|
Option 4 : Amount |
Option 3 : Amount of |
of memory |
memory required by the |
required for the |
program to run |
program to |
|
compile |
Ques 45 : Choose the correct answer
The memory space needed by an algorithm has a fixed part independent of the problem instance solved and a variable part which changes according to the problem instance solved. In general, which of these two is of prime concern to an algorithm designer?
|
Option 2 : Variable |
Option 3 : Product of |
Option 4 : None of |
|
Option 1 : Fixed part |
fixed part and variable |
|||
Part |
these |
|||
|
|
part |
|
|
|
|
|
|
|
|
|
|
|
Ques 46 : Choose the correct answer
While calculating time complexity of an algorithm, the designer concerns himself/herself primarily with the run time and not the compile time. Why?
|
|
|
Option 4 : A |
Option 1 : Run time is |
Option 2 : Compile |
Option 3 : Compile time |
program needs to |
always more than |
time is always more |
be compiled once |
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
14/41 |
10/13/2014 |
|
tech.htm |
compile time. |
than run time. |
is a function of run time. but can be run |
|
|
several times. |
Ques 47 : Choose the correct answer
Pankaj and Mythili were both asked to write the code to evaluate the following expression: a - b +
Pankaj writes the following code statements (Code A): print
Mythili writes the following code statements (Code B): d =
print d + c/d + d*d
If the time taken to load a value in a variable, for addition, multiplication or division between two operands is same, which of the following is true?
Option 1 : Code A uses Option 2 : Code A uses
lesser memory and is |
lesser memory and is |
slower than Code B |
faster than Code B |
Option 3 : Code A uses more memory and is faster than Code B
Option 4 : Code A uses more memory and is slower than Code B
Ques 48 : Choose the correct answer
Vrinda writes an efficient program to sum two square diagonal matrices (matrices with elements only on diagonal). The size of each matrix is nXn. What is the time complexity of Vrinda's algorithm?
Option 1 : θ(n^2) |
Option 2 : θ(n) |
Option 3 : θ(n*log(n)) |
Option 4 : None of |
|
these |
||||
|
|
|
||
|
|
|
|
|
|
|
|
|
Ques 49 : Choose the correct answer
Tarang writes an efficient program to add two upper triangular 10X10 matrices (elements on diagonal retained). How many total additions will his program make?
Option 1 : 100 |
Option 2 : 55 |
Option 3 : 25 |
Option 4 : 10 |
|
|
|
|
|
|
|
|
Ques 50 : Choose the correct answer
Ravi and Rupali are asked to write a program to sum the rows of a 2X2 matrices stored in the array A.
Ravi writes the following code (Code A): for n = 0 to 1
sumRow1[n] = A[n][1] + A[n][2] end
Rupali writes the following code (Code B): sumRow1[0] = A[0][1] + A[0][2] sumRow1[1] = A[1][1] + A[1][2]
Comment upon these codes (Assume no
Option 1 : Code A will Option 2 : Code B will |
Option 4 : Code B |
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
15/41 |
10/13/2014 |
|
tech.htm |
|
execute faster than |
execute faster than |
Option 3 : Code A is |
is logically |
Code B. |
Code A |
logically incorrect. |
incorrect. |
Ques 51 : Choose the correct answer
There is an array of size n initialized with 0. Akanksha has to write a code which inserts the value
3k at position 3k in the array, where k=0,1…(till possible). Akanksha writes an efficient code to do so. What is the time complexity of her code?
Option 1 : θ(n^2) |
Option 2 : θ(n) |
Option 3 : θ(log3(n)) |
Option 4 : θ(3n) |
|
|
|
|
Ques 52 : Choose the correct answer
There are two matrices A and B of size nXn. The data in both these matrices resides only at positions where both the indices are a perfect square. Rest all positions have 0 as the data. Manuj has available a third matrix initialized with 0's at all positions. He writes an efficient code to put the sum of A and B in C. What is the time complexity of Manuj's program?
Option 1 : θ(n^2) |
Option 2 : θ(n) |
Option 3 : θ(n1/2) |
Option 4 : |
|
θ(log(n)) |
||||
|
|
|
||
|
|
|
|
|
|
|
|
|
Ques 53 : Choose the correct answer
Ravi has to add an strictly upper triangular (no elements at diagonal) and a strictly lower triangular square matrix (no elements at diagonal) and put the result in a third matrix. What is the time complexity of Ravi's algorithm? Assume that storing a value in a memory space takes negligible time, while each addition between values takes the dominating amount of time.
Option 1 : θ(n^2) |
Option 2 : θ(n) |
Option 3 : θ(1) |
Option 4 : None of |
|
these |
||||
|
|
|
||
|
|
|
|
|
|
|
|
|
Ques 54 : Choose the correct answer
We have two 100X3 (rowsXcolumn) matrices containing
|
|
|
Option 4 : The |
Option 1 : Code A is |
Option 2 : Code B is |
Option 3 : Code A and |
comparison |
Code B will run in the |
between the speed |
||
faster than Code B |
faster than Code A |
same amount of time |
of the codes cannot |
|
|
||
|
|
|
be made. |
|
|
|
|
|
|
|
|
Ques 55 : Choose the correct answer
A code takes the following code steps (equivalently time unit) to execute: 5*n3 + 6*n2 + 1. Which of the following is not true about the time complexity of the program?
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
16/41 |
10/13/2014 |
|
tech.htm |
|
||
Option 1 : It has a time Option 2 : It has a time |
Option 3 : It has a time |
Option 4 : It has a |
|||
complexity of O(n3) |
complexity of O(n4) |
complexity of O(n2) |
time complexity of |
||
θ(n3) |
|||||
|
|
|
|
||
|
|
|
|
|
Ques 56 : Choose the correct answer
We have two programs. We know that the first has a time complexity O(n2), while the second has a complexity ω(n2). For sufficiently large n, which of the following cannot be true?
Option 2 : The first Option 1 : Both codes code has higher time have same complexity complexity than the
second
Option 3 : The second |
|
code has lower time |
Option 4 : Both |
complexity than the first |
codes are the same. |
code. |
|
Ques 57 : Choose the correct answer
The time complexity of code A is θ(n), while for Code B it is θ(log(n)). Which of the following is true for sufficiently large n?
Option 1 : Both code have the same time complexity
Option 2 : Code A has |
Option 3 : Code B has |
higher time complexity |
higher time complexity |
Option 4 : No comparison can be made between the time complexity of the two codes.
Ques 58 : Choose the correct answer
Rajini is given an efficient code for summing two nXn matrices and putting the result in a third matrix. She is asked to find it's time complexity. She realizes that the number of iterations required is more than n. What can she claim with regard to the complexity of the code?
Option 1 : It is O(n) |
Option 2 : It is O(n2) |
Option 3 : It is θ(n) |
Option 4 : It is |
|
ω(n) |
||||
|
|
|
||
|
|
|
|
|
|
|
|
|
Ques 59 : Choose the correct answer
Gautam is given two codes, A and B, to solve a problem, which have complexity θ(n) and θ(n2) respectively. His client wants to solve a problem of size k, which Gautam does not know. Which code will Gautam deliver to the client, so that the execution is faster?
Option 4 : Both
Option 3 : Gautam cannot codes have the Option 1 : Code A Option 2 : Code B determine same execution time, so deliver
any.
Ques 60 : Choose the correct answer
Surbhi is given two codes, A and B, to solve a problem, which have complexity O(n3) and ω(n4) respectively. Her client wants to solve a problem of size k, which is sufficiently large. Which code will Surbhi deliver to the client, so that the execution is faster?
Option 4 : Both
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
17/41 |
10/13/2014 |
|
tech.htm |
|
|
Option 1 : Code A |
Option 2 : Code B |
Option 3 : Surbhi cannot |
codes have the |
|
determine |
same execution |
|||
|
|
|
time, so deliver |
|
|
|
|
|
|
|
|
|
|
any. |
|
|
|
|
|
|
|
|
|
|
Ques 61 : Choose the correct answer
Vibhu is given two codes, A and B, to solve a problem, which have complexity O(n4) and ω(n3) respectively. Her client wants to solve a problem of size k, which is sufficiently large. Which code will Gautam deliver to the client, so that the execution is faster?
|
|
|
Option 4 : Both |
|
|
Option 3 : Vibhu cannot |
codes have the |
Option 1 : Code A |
Option 2 : Code B |
same execution |
|
|
|
determine |
time, so deliver |
|
|
|
any. |
|
|
|
|
|
|
|
|
Ques 62 : Choose the correct answer
Pavithra is given two codes, A and B, to solve a problem, which have complexity θ(n3) and ω(n3) respectively. Her client wants to solve a problem of size k, which is sufficiently large. Which code should she deliver to the client in the present scenario?
|
|
Option 3 : Both codes |
Option 4 : None of |
|
Option 1 : Code A |
Option 2 : Code B |
have the same execution |
||
these |
||||
|
|
time, so deliver any. |
|
|
|
|
|
|
|
|
|
|
|
Ques 63 : Choose the correct answer
Code A has to execute 4*n2 + 64 program statements, while Code B has to execute 32*n program statements for a problem of size n. The time for executing a single program statement is same for all statements. Rajesh was given a problem with a certain size k and he delivered Code A. What could be the possible value of k?
Option 1 : 1000 |
Option 2 : 5 |
Option 3 : 10 |
Option 4 : 3 |
|
|
|
|
|
|
|
|
Ques 64 : Choose the correct answer
Saumya writes a code which has a function which calls itself. Which programming concept is Saumya using?
Option 1 : This is bad |
|
|
|
programming practice |
Option 2 : Recursion |
Option 3 : Decision |
Option 4 : |
and should not be |
Making |
Overloading |
|
done. |
|
|
|
|
|
|
|
|
|
|
|
Ques 65 : Choose the correct answer
Shrishti writes the code for a function that computes the factorial of the inputted number n.
function factorial(n)
{
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
18/41 |
10/13/2014
if(n equals 1) return 1 else
}
Fill in the missing statement.
Option 1 : return |
Option 2 : return |
n*factorial(n) |
tech.htm
Option 3 : return |
Option 4 : return |
Ques 66 : Choose the correct answer
Tanuj writes the code for a function that takes as input n and calculates the sum of first n natural numbers.
Function sum( n )
{
if(??) return 1 else
return (n +
} |
|
Fill in ?? in the code. |
|
Option 1 : n equals 1 Option 2 : n equals 2 Option 3 : n >= 1 |
Option 4 : n > 1 |
Ques 67 : Choose the correct answer
Saloni writes the code for a function that takes as input n, an even integer and calculates the sum of first n even natural numbers.
function sum( n )
{
if(n equals 2) return 2 else
return (n +
}
She then calls the function by the statement, sum(30). How many times will the function sum be called to compute this sum.
Option 1 : 1 |
Option 2 : 30 |
Option 3 : 15 |
Option 4 : 16 |
|
|
|
|
|
|
|
|
Ques 68 : Choose the correct answer
Consider the following function
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
19/41 |
10/13/2014 |
tech.htm |
function calculate( n )
{
if(n equals 5) return 5 else
return (n +
}
Shishir calls the function by the statement, calculate(20). What value will the function return?
Option 1 : 50 |
Option 2 : 200 |
Option 3 : 35 |
Option 4 : 20 |
|
|
|
|
|
|
|
|
Ques 69 : Choose the correct answer
Ravi is writing a program in C++. C++ uses the 'for' keyword for loops. Due to distraction, Ravi writes 'gor' instead of 'for'. What will this result to?
Option 1 : The code |
Option 2 : The code |
will give an error while |
|
will not compile. |
in execution |
|
Option 3 : The code may |
Option 4 : It will |
work for some inputs and |
create no |
not for others. |
problems. |
Ques 70 : Choose the correct answer
What does a compiler do?
Option 1 : Converts |
Option 2 : Necessarily |
code from a high level |
converts the code into |
language to a low level |
assembly language |
language |
|
|
Option 4 : |
Option 3 : Converts code |
Necessarily |
from a low level language |
converts the code |
to a high level language |
into machine |
|
language |
Ques 71 : Choose the correct answer
A program is compiled by Tarun on his machine. Whether it will run on a different computer will depend upon:
Option 1 : Operating |
Option 2 : Hardware |
Option 3 : Both operating |
Option 4 : The |
system on the |
configuration of the |
system and hardware |
language of the |
computer |
computer |
configuration |
program |
|
|
|
|
|
|
|
|
Ques 72 : Choose the correct answer
Sakshi writes a code in a
Option 1 : An |
Option 2 : A compiler |
Option 3 : A cross- |
Option 4 : Linker |
interpreter |
|
compiler |
|
|
|
|
|
|
|
|
|
Ques 73 : Choose the correct answer
Shahaana has a 10,000 line code. She is trying to debug it. She knows there is a logical error in the first 25 lines of the code. Which of the following will be an efficient way of debugging:
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
20/41 |
10/13/2014 |
tech.htm |
Option 1 : Compile the whole code and step into it line by line
Option 2 : Use an |
Option 3 : Compile the |
Option 4 : None of |
|
interpreter on the first |
|||
whole code and run it |
these |
||
25 lines. |
|
|
Ques 74 : Choose the correct answer
Farhan writes a code to find the factorial of an inputted number. His code gives correct answer for some inputs and incorrect answers for others. What kind of error does his program have?
Option 1 : Syntactical |
Option 2 : |
Option 3 : Logical Error |
Option 4 : None of |
error |
Error |
these |
|
|
|
|
|
|
|
|
|
Ques 75 : Choose the correct answer
Reshama is debugging a piece of code which takes several iterations of modifying and executing code, while Mohammad has to deliver a product to the customer, which the customer will run multiple times. Reshama wants her debug cycle to take minimum possible time, while Mohammad wants that his products run time is minimum. What tools should Reshama and Mohammad respectively use on their code?
Option 1 : Compiler, |
Option 2 : Interpreter, |
Option 3 : Compiler, |
Option 4 : |
|
Interpreter, |
||||
Interpreter |
Compiler |
Compiler |
||
Interpreter |
||||
|
|
|
||
|
|
|
|
|
|
|
|
|
Ques 76 : Choose the correct answer
Gautam writes a program to run on a Motorola processor on his Pentium computer. He wants to see how the program will execute on the Motorola processor using his Pentium machine. What tool will he use?
Option 1 : Compiler |
Option 2 : Interpreter Option 3 : Assembler |
Option 4 : |
|
Simulator |
|||
|
|
||
|
|
|
|
|
|
|
Ques 77 : Choose the correct answer
Consider the following code:
function modify(y,z)
{
y = y + 1; z = z + 1; return y - z
}
function calculate( )
{
integer a = 5, b = 10, c
c = modify(a, b); print a
print space print c
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
21/41 |
10/13/2014 |
tech.htm |
}
Assume that a and b were passed by value. What will be the output on executing function calculate( )?
Option 1 : 11 |
Option 2 : 10 |
Option 3 : 6 |
Option 4 : 5 |
|
|
|
|
|
|
|
|
Ques 78 : Choose the correct answer
Consider the following code:
function modify(b,a)
{
return a - b
}
function calculate( )
{
integer a = 5, b = 12, c
c = modify(a, b); print c
}
Assume that a and b were passed by reference. What will be the output of the program on executing function calculate( ) ?
Option 1 : 7 |
Option 2 : |
Option 3 : Error |
Option 4 : 8 |
|
|
|
|
|
|
|
|
Ques 79 : Choose the correct answer
Consider the following code:
function modify(y,z)
{
y = y + 1 z = z + 1 return y - z
}
function calculate( )
{
integer a = 12, b = 20, c
c = modify(a, b); print a
print space print c
}
Assume that a and b were passed by reference. What will be the output of the function calculate( )
?
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
22/41 |
10/13/2014 |
|
tech.htm |
|
|
|
Option 1 : 12 |
Option 2 : 13 |
Option 3 : 12 8 |
Option 4 : 13 8 |
|
|
|
|
|
|
|
|
|
|
Ques 80 : Choose the correct answer
Afzal writes a piece of code, where a set of three lines occur around 10 times in different parts of the program. What programming concept can he use to shorten his program code length?
Option 1 : Use for |
Option 2 : Use |
Option 3 : Use arrays |
Option 4 : Use |
|
loops |
functions |
classes |
||
|
||||
|
|
|
|
|
|
|
|
|
Ques 81 : Choose the correct answer
Geetika writes a piece of code, where a set of eight lines occur around 10 times in different parts of the program (Code A). She passes on the code to Deva. Deva puts the set of eight lines in a function definition and calls them at the 10 points in the program (Code B). Which code will run faster using an interpreter?
|
|
Option 3 : Code A and |
Option 4 : None of |
Option 1 : Code A |
Option 2 : Code B |
Code B will run with the |
|
|
|
same speed |
these |
|
|
|
|
|
|
|
|
|
|
|
|
Ques 82 : Choose the correct answer
Consider the following code:
function modify(a,b)
{
integer c, d = 2 c = a*d + b return c
}
function calculate( )
{
integer a = 5, b = 20, c integer d = 10
c = modify(a, b); c = c + d
print c
}
Assume that a and b were passed by value. What will be the output of the function calculate( ) ?
Option 1 : 80 |
Option 2 : 40 |
Option 3 : 32 |
Option 4 : 72 |
|
|
|
|
|
|
|
|
Ques 83 : Choose the correct answer
Consider the following code:
function modify(w,u)
{
w = w + 2
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
23/41 |
10/13/2014 |
tech.htm |
u = u - 3 return (w - u)
}
function calculate( )
{
integer a = 10, b = 20, c c = modify(a, b); print a
print space print b
}
Assume that a was passed by value and b was passed by reference. What will be the output of the program on executing function calculate( ) ?
Option 1 : 12 17 |
Option 2 : 10 17 |
Option 3 : 12 20 |
Option 4 : 10 20 |
|
|
|
|
|
|
|
|
Ques 84 : Choose the correct answer
Consider the following function:
function run( )
{
integer a = 0 // Statement 1 while (a < 5)
{
integer c = 0 // Statement 2 c = c + 1 // Statement 3
a = a + 1
}
print c // Statement 4
}
At which statement in this program will the compiler detect an error?
Option 1 : Statement 1 Option 2 : Statement 2 Option 3 : Statement 3 |
Option 4 : |
Statement 4 |
|
|
|
|
|
Ques 85 : Choose the correct answer
Which one of the following is the lowest level format to which the computer converts a higher language program before execution?
Option 1 : English |
Option 2 : Machine |
Option 3 : Assembly |
Option 4 : System |
code |
Code |
Language |
Language |
|
|
|
|
|
|
|
|
Ques 86 : Choose the correct answer
If you want to write a function that swaps the values of two variables, you must pass them by:
Option 1 : Value only |
Option 2 : Reference |
Option 3 : Either A or B |
Option 4 : Neither |
only |
A nor B |
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
24/41 |
10/13/2014 |
tech.htm |
|
|
|
|
|
|
|
Ques 87 : Choose the correct answer
Consider the following code:
if (condition 1) { if (condition 2)
{// Statement A } else
if (condition 3)
{// Statement B } else
{// Statement C }
else
if (condition 4)
{// Statement D } else
{// Statement E}
}
Which of the following conditions will allow execution of statement C?
|
|
|
Option 4 : |
Option 1 : condition1 |
Option 2 : condition1 |
Option 3 : |
condition1 AND |
AND condition4 AND |
NOT(condition2) AND |
NOT(condition2) |
|
AND condition3 |
!condition2 |
NOT(condition3) |
AND |
|
|
|
NOT(condition3) |
|
|
|
|
|
|
|
|
Ques 88 : Choose the correct answer
Consider the following code:
if (condition 1) { if (condition 2)
{ // Statement A } else
if (condition 3) { // Statement B} else
{// Statement C } else
if (condition 4) {// Statement D} else
{// Statement E}
}
Which of the following conditions will allow execution of statement E?
|
|
|
Option 4 : |
|
Option 2 : |
Option 3 : |
condition1 AND |
Option 1 : condition1 |
NOT(condition1) AND |
condition4 AND |
|
AND condition3 |
condition2 AND |
NOT(condition2) AND |
NOT(condition2) |
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
25/41 |
10/13/2014 |
tech.htm |
|
|
|
NOT(condition4) |
NOT(condition3) |
AND |
|
|
|
NOT(condition3) |
|
|
|
|
|
|
|
|
Ques 89 : Choose the correct answer |
|
|
|
Consider the following code: |
|
|
|
if (condition 1) { |
|
|
|
if (condition 2) |
|
|
|
|
{ // Statement A } |
|
|
|
else |
|
|
|
if (condition 3) |
|
|
|
{ // Statement B} |
|
|
|
else |
|
|
|
{// Statement C } |
|
|
else |
|
|
|
|
if (condition 4) |
|
|
|
{// Statement D} |
|
|
|
else |
|
|
|
{// Statement E} |
|
|
} |
|
|
Which of the following condition will allow execution of statement A?
Option 1 : |
Option 2 : condition1 |
|
Option 4 : |
Option 3 : condition1 |
NOT(condition1) |
||
NOT(condition2) |
AND condition4 AND |
AND condition2 AND |
AND condition2 |
AND |
NOT(condition2) AND condition4 |
AND |
|
NOT(condition3) |
NOT(condition3) |
|
NOT(condition4) |
|
|
|
|
|
|
|
|
|
|
|
|
Ques 90 : Choose the correct answer
What does the following function do?
function operation (int a, int b)
{
if (a < b)
{return operation(b, a) } else
{return a }
} |
|
|
Option 1 : Returns the |
Option 2 : Returns the |
Option 4 : Always |
Option 3 : Loops forever returns the second |
||
max of (a,b) |
min of (a,b) |
parameter |
|
|
|
|
|
|
|
|
|
Ques 91 : Choose the correct answer
What does the following function do?
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
26/41 |
10/13/2014
function operation (int a, int b)
{
if (a > b)
{return operation(b, a) } else
{return a; }
} |
|
|
Option 1 : Always |
Option 2 : Returns the |
|
returns the first |
||
min of (a,b) |
||
parameter |
||
|
tech.htm
Option 3 : Returns the |
Option 4 : Loops |
max of (a,b) |
forever |
Ques 92 : Choose the correct answer
function g(int n)
{
if (n > 0) return 1; else return
}
function f(int a, int b)
{
if (a > b) return
}
If f(a,b) is called, what is returned?
Option 1 : Always |
Option 2 : 1 if a > b, |
if a < b, 0 otherwise |
Option 3 :
Option 4 : 0 if a equals b,
Ques 93 : Choose the correct answer
function g(int n)
{
if (n > 0) return 1; else return
}
function f(int a, int b)
{
if (a > b) return
}
If f(a,b) is called, what is returned?
Option 1 : 1 if a > b,
Option 3 : 0 if a equals b, |
Option 4 : |
b, 1 if a < b, 0 |
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
27/41 |
10/13/2014 |
tech.htm |
|
if a < b, 0 otherwise |
+1 otherwise |
otherwise |
Ques 94 : Choose the correct answer
function g(int n)
{
if (n > 0) return 1; else return
}
function f(int a, int b)
{
if (a > b) return
}
If f(a,b) is called, what is returned?
Option 1 : Always +1 |
Option 2 : 1 if a > b, |
if a < b, 0 otherwise |
Option 3 :
Option 4 : 0 if a equals b,
Ques 95 : Choose the correct answer
function g(int n)
{
if (n > 0) return 1; else return
}
function f(int a, int b)
{
if (a > b) return
}
If f(a,b) is called, what is returned?
Option 2 :
Option 3 : 1 if a > b,
Option 4 : 0 if a equals b,
Ques 96 : Choose the correct answer
Consider the following code:
for i= m to n increment 2 { print "Hello!" }
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
28/41 |
10/13/2014 |
tech.htm |
Assuming m < n and exactly one of (m,n) is even, how many times will Hello be printed?
Option 1 : (n - m + 1)/2
Option 3 : 1 + (n - m)/2 if Option 2 : 1 + (n - m)/2 m is even, (n - m + 1)/2 if
m is odd
Option 4 : (n - m + 1)/2 if m is even, 1 + (n - m)/2 if m is odd
Ques 97 : Choose the correct answer
Consider the following code:
for i= m to n increment 2 { print "Hello!" }
Assuming m < n and (m,n) are either both even or both odd, How many times will Hello be printed?
Option 1 : (n - m + 1)/2
Option 3 : 1 + (n - m)/2 if Option 2 : 1 + (n - m)/2 m is even, (n - m + 1)/2 if
m is odd
Option 4 : (n - m + 1)/2 if m is even, 1 + (n - m)/2 if m is odd
Ques 98 : Choose the correct answer
Assuming n > 2, What value does the following function compute for odd n?
function f (int n)
{
if (n equals 1) { return 1 }
if (n equals 2) { return
}
Option 1 : 1 + 2 + 3 + Option 2 : 1 + 3 + 5 + 7 Option 3 : n/2 + (1 + 3 + 5 Option 4 : 1 + (1 + 4 + ... + n + ... + n + 7 + ... + n) 3 + 5 + 7 + ... + n)
Ques 99 : Choose the correct answer
Assuming n > 2, What value does the following function compute for even n?
int f (int n)
{
if (n equals 1) { return 1 }
if (n equals 2) { return
}
Option 1 : 1 + 2 + 3 + |
Option 2 : 1 + (2 + 4 + Option 3 : 1 + n/2 + (4 + 6 Option 4 : 2 + 4 + |
||
4 + + n... |
6 + 8 + ... + n) |
+ 8 + ... + n) |
6 + 8 + ... + n |
|
|
|
|
|
|
|
|
Ques 100 : Choose the correct answer
The for loop is equivalent to a while loop when
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
29/41 |
10/13/2014 |
|
tech.htm |
|
|
|
Option 1 : There is no |
Option 2 : There is no |
Option 3 : A and B |
Option 4 : It is |
|
initialization |
increment expression |
combined are true |
never equivalent |
|
expression |
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ques 101 : Choose the correct answer
Consider the statement while (a < 10.0) { a = a*a }
Assuming a is positive, for what value of a will this code statement result in an infinite loop?
Option 1 : a < 1.0 |
Option 2 : a < sqrt(10) Option 3 : a > sqrt(10) |
Option 4 : a = 0 |
|
|
|
|
|
|
Ques 102 : Choose the correct answer
int area(double radius)
{
return PI*radius*radius;
}
Which of the following is always true about the function area?
Option 1 : It returns |
Option 2 : It returns the |
Option 3 : It returns the |
|
area of a circle within the |
|||
the area of a circle |
area of a circle within |
limits of precision of |
|
within the limits of |
the limits of the |
double, or the constant PI, |
|
double precision. |
constant PI. |
||
whichever is lower. |
|||
|
|
Option 4 : None of the above.
Ques 103 : Choose the correct answer
What does this function compute for positive n?
function f(int n)
{
if (n equals 1)
{return 1 } else
{return
}
Option 1 : 1 + n |
Option 2 : 1 + 2 + 3 + |
Option 3 : 1 + n, if n > 1, |
Option 4 : None of |
|
... + n |
1 otherwise |
the above |
||
|
||||
|
|
|
|
|
|
|
|
|
Ques 104 : Choose the correct answer
Which of these is not a data type?
Option 1 : integer |
Option 2 : character |
Option 3 : boolean |
Option 4 : array |
|
|
|
|
|
|
|
|
Ques 105 : Choose the correct answer
The construct "if (condition) then A else B" is for which of the following purposes?
Option 4 : Object
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
30/41 |
10/13/2014 |
tech.htm |
|
Option 1 : Decision- Option 2 : Iteration |
Option 3 : Recursion |
Oriented |
Making |
|
Programming |
Ques 106 : Choose the correct answer
In a sequential programming language, code statements are executed in which order?
Option 1 |
: All are |
Option 2 : From top to |
Option 3 |
: From bottom to Option 4 : None of |
|
executed |
|
||||
|
bottom |
top |
|
these |
|
simultaneously |
|
||||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
Ques 107 : Choose the correct answer |
|
|
|
||
A |
|
||||
Option 1 |
: Decision- Option 2 : Iteration |
Option 3 |
: Recursion |
Option 4 : None of |
|
Making |
|
|
|
|
these |
|
|
|
|
|
|
|
|
|
|
|
|
Ques 108 : Choose the correct answer
There are two loops which are nested. This implies which one of the following?
Option 1 : Two loop, |
Option 2 : Two loops, |
one after the other |
one inside the others |
Option 3 : One loop with two different iteration counts
Option 4 : Two loops with the same iteration count
Ques 109 : Choose the correct answer
How will 47 be stored as an unsigned
Option 1 : 10111101 Option 2 : 00101111 |
Option 3 : 10111000 |
Option 4 : |
|
00101101 |
|||
|
|
Ques 110 : Choose the correct answer
An integer X is saved as an unsigned
Option 1 : 22 |
Option 2 : 11 |
Option 3 |
: 10 |
Option 4 : None of |
|
these |
|||||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
Ques 111 : Choose the correct answer |
|
|
|
||
A variable cannot be used… |
|
|
|
||
Option 1 : Before it is |
Option 2 : After it is |
Option 3 |
: In the function |
Option 4 : Can |
|
declared |
declared |
it is declared in |
always be used |
||
|
|
|
|
||
|
|
|
|
||
Ques 112 : Choose the correct answer |
|
|
|
||
What is implied by the argument of a function? |
|
|
|||
Option 1 : The |
Option 2 : The value it |
Option 3 |
: The execution |
Option 4 : Its |
|
variables passed to it |
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
31/41 |
10/13/2014 |
|
tech.htm |
|
|
|
when it is called |
returns on execution |
code inside it |
return type |
|
|
|
|
|
|
|
|
|
|
|
Ques 113 : Choose the correct answer |
|
|
|
|
Which of the following is true about comments? |
|
||
|
Option 1 : They are |
Option 2 : They are not |
Option 3 : A good |
Option 4 : They |
|
executed only once. |
executed |
program does not contain |
increase program |
|
them |
execution time. |
||
|
|
|
||
|
|
|
|
|
|
|
|
|
|
Ques 114 : Choose the correct answer
Neelam wants to share her code with a colleague, who may modify it. Thus she wants to include the date of the program creation, the author and other information with the program. What component should she use?
Option 4 : Option 1 : Header files Option 2 : Iteration Option 3 : Comments Preprocessor
directive
Ques 115 : Choose the correct answer
Shashi writes a program in C++ and passes it on to Pankaj. Pankaj does some indentation in some statements of the code. What will this lead to?
Option 1 : Faster |
Option 2 : Lower |
Option 3 : Correction of |
Option 4 : Better |
Execution |
memory requirement |
errors |
readability |
|
|
|
|
|
|
|
|
Ques 116 : Choose the correct answer
Zenab and Shashi independently write a program to find the the mass of one mole of water, which includes mass of hydrogen and oxygen. Zenab defines the variables:
integer hydrogen, oxygen, water // Code A while Shashi defines the three quantities as: integer a, b, c // Code B
Which is a better programming practice and why?
|
Option 2 : Code A is |
|
Option 1 : Code B is |
better because the |
Option 3 : Code A will |
better because variable |
variable names are |
run correctly, while Code |
names are shorter |
understandable and |
B will give an error. |
|
|
Option 4 : Code B will run correctly, while Code A will give an error.
Ques 117 : Choose the correct answer
For solving a problem, which of these is the first step in developing a working program for it?
Option 1 : Writing the program in the programming language
Option 2 : Writing a |
Option 3 : Compiling the |
Option 4 : Code |
to solve the problem. |
libraries required. |
debugging |
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
32/41 |
10/13/2014 |
tech.htm |
Ques 118 : Choose the correct answer
A robust program has which one of the following features?
Option 1 : It runs |
Option 2 : It is robust |
Option 3 : It can handle |
correctly on some |
incorrect input data or |
|
inputs |
to hardware damage |
data types. |
Option 4 : None of these
Ques 119 : Choose the correct answer
Tarun wants to write a code to divide two numbers. He wants to warn the user and terminate the program if he or she enters 0 as the divisor. Which programming construct can he use to do this?
Option 1 : Iteration |
Option 2 : Decision- |
Option 3 : Recursion |
Option 4 : None of |
|
making |
|
these |
|
|
|
|
|
|
|
|
Ques 120 : Choose the correct answer
To solve a problem, it is broken in to a sequence of smaller
Option 1 : |
Option 2 : |
Option 3 : Procedural |
Option 4 : None of |
Approach |
Approach |
Programming |
these |
|
|
|
|
|
|
|
|
Ques 121 : Choose the correct answer
The time complexity of linear search algorithm over an array of n elements is
Option 1 : O (log2 n) Option 2 : O (n) |
Option 3 : O (n log2 n ) Option 4 : O (n2) |
|
|
Ques 122 : Choose the correct answer
Rajesh implements queue as a
Option 1 : O (1) |
Option 2 : O (log2 n) |
Option 3 : O (n) |
Option 4 : O (n |
|
log2 n ) |
||||
|
|
|
||
|
|
|
|
Ques 123 : Choose the correct answer
The time required to insert an element in a stack with linked list implementation is
Option 1 : O (1) |
Option 2 : O (log2 n) |
Option 3 : O (n) |
Option 4 : O (n |
|
log2 n ) |
||||
|
|
|
||
|
|
|
|
Ques 124 : Choose the correct answer
In the following sorting procedures, which one will be the slowest for any given array?
Option 1 : Quick sort Option 2 : Heap sort |
Option 3 : Merge Sort |
Option 4 : Bubble |
|
sort |
|||
|
|
||
|
|
|
|
|
|
|
Ques 125 : Choose the correct answer
Pankaj stores n data elements in a hash table. He is able to get the best efficiency achievable by a
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
33/41 |
10/13/2014 |
tech.htm |
hash table. What is the time complexity of accessing any element from this hash table?
Option 1 : O(1) |
Option 2 : O(n2) |
Option 3 : O(log n) |
Option 4 : O(n) |
|
|
|
|
Ques 126 : Choose the correct answer
Every element of a data structure has an address and a key associated with it. A search mechanism deals with two or more values assigned to the same address by using the key. What is this search mechanism?
Option 1 : Linear |
Option 2 : Binary |
Option 3 : Hash Coded |
Option 4 : None of |
Search |
search |
Search |
these |
|
|
|
|
|
|
|
|
Ques 127 : Choose the correct answer
The order of magnitude of the worst case performance of a hash coded search (over N elements) is
Option 1 : N |
Option 2 : N log2 N |
Option 3 : log2 N |
Option 4 : not |
|
dependent upon N |
||
|
|
|
|
|
|
|
|
|
|
|
|
Ques 128 : Choose the correct answer
A sorting algorithm traverses through a list, comparing adjacent elements and switching them under certain conditions. What is this sorting algorithm called?
Option 1 : insertion |
Option 2 : heap sort |
Option 3 : quick sort |
Option 4 : bubble |
sort |
|
|
sort |
|
|
|
|
|
|
|
|
Ques 129 : Choose the correct answer
A sorting algorithm iteratively traverses through a list to exchange the first element with any element less than it. It then repeats with a new first element. What is this sorting algorithm called?
Option 1 : insertion |
Option 2 : selection |
Option 3 : heap sort |
Option 4 : quick |
|
sort |
sort |
sort |
||
|
||||
|
|
|
|
|
|
|
|
|
Ques 130 : Choose the correct answer
A sort which uses the binary tree concept such that any number in the tree is larger than all the numbers in the subtree below it is called
Option 1 : selection |
Option 2 : insertion sort Option 3 : heap sort |
Option 4 : quick |
sort |
|
sort |
|
|
|
|
|
|
Ques 131 : Choose the correct answer
The average time required to perform a successful sequential search for an element in an array A(1 : n) is given by
Option 1 : (n+1) / 2 |
Option 2 : log2n |
Option 3 : n(n+1) / 2 |
Option 4 : n2 |
|
|
|
|
Ques 132 : Choose the correct answer
How many comparisons are needed to sort an array of length 5 if a straight selection sort is used
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
34/41 |
10/13/2014 |
tech.htm |
and array is already in the opposite order?
Option 1 : 1 |
Option 2 |
: 10 |
Option 3 |
: 50 |
Option 4 |
: 20 |
|
|
|
|
|
||
|
|
|
|
|
||
Ques 133 : Choose the correct answer |
|
|
|
|
||
Queues serve a major role in |
|
|
|
|
|
|
Option 1 : simulation |
Option 2 |
: simulation |
Option 3 |
: simulation of |
Option 4 |
: |
limited resource |
expression |
|||||
of recursion |
of arbitrary linked list |
allocation |
evaluation |
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ques 134 : Choose the correct answer
The average search time of hashing with linear probing will be less if the load factor
Option 1 : is far less |
Option 2 : equals one |
Option 3 : is far greater |
Option 4 : none of |
than one |
than one |
these |
|
|
|
|
|
|
|
|
|
Ques 135 : Choose the correct answer |
|
|
|
Number of vertices of odd degree in a graph is |
|
||
Option 1 : is always |
Option 2 : always odd |
Option 3 : either even or |
Option 4 : always |
even |
odd |
zero |
|
|
|
|
|
|
|
|
|
Ques 136 : Choose the correct answer |
|
|
|
The algorithm design technique used in the quick sort algorithm is |
|
||
Option 1 : Dynamic |
Option 2 : Back |
Option 3 : Divide and |
Option 4 : Greedy |
programming |
tracking |
conquer |
Search |
|
|
|
|
|
|
|
|
Ques 137 : Choose the correct answer |
|
|
|
Linked lists are not suitable for |
|
|
|
Option 1 : Insertion |
Option 2 : Binary |
Option 3 : Queue |
Option 4 : None of |
sort |
search |
implementation |
these |
|
|
|
|
|
|
|
|
Ques 138 : Choose the correct answer
A connected graph is the one which
Option 1 : Cannot be partitioned without removing an edge
Option 2 : Can be |
Option 3 : does not |
Option 4 : Has |
|
partitioned without |
even number of |
||
contain a cycle |
|||
removing an edge |
vertices |
||
|
Ques 139 : Choose the correct answer |
|
|
Stack is useful for implementing |
|
|
Option 2 : breadth first |
|
Option 4 : none of |
Option 1 : radix search search |
Option 3 : recursion |
these |
|
|
|
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
35/41 |
10/13/2014 |
tech.htm |
Ques 140 : Choose the correct answer
Which of the following is useful in traversing a given graph by breadth first search?
Option 1 : stack |
Option 2 : set |
Option 3 : list |
Option 4 : queue |
|
|
|
|
|
|
|
|
Ques 141 : Choose the correct answer
Which of the following is useful in implementing quick sort?
Option 1 : stack |
Option 2 : set |
Option 3 : list |
Option 4 : queue |
|
|
|
|
|
|
|
|
Ques 142 : Choose the correct answer
Which of the following abstract data types can be used to represent a
Option 1 : Tree |
Option 2 : Stack |
Option 3 : Graph |
Option 4 : Queue |
|
|
|
|
|
|
|
|
Ques 143 : Choose the correct answer
Two lists, A and B are implemented as singly linked
Option 1 : lastB |
Option 2 : lastA = |
Option 3 : |
Option 4 : lastB = |
next = firstA |
firstB |
firstB |
firstA |
|
|
|
|
|
|
|
|
Ques 144 : Choose the correct answer
Which of the following sorting algorithms yield approximately the same
Option 1 : Bubble sort |
Option 2 : Heap sort |
Option 3 : Quick sort and |
Option 4 : Tree |
sort and Median- |
|||
and Selection sort |
and Merge sort |
Radix sort |
|
|
|
|
|
|
|
|
|
|
|
|
|
Ques 145 : Choose the correct answer
A complete binary tree with 5 levels has how many nodes? (Root is Level 1)
Option 1 : 15 |
Option 2 : 25 |
Option 3 : 63 |
Option 4 : 31 |
|
|
|
|
|
|
|
|
Ques 146 : Choose the correct answer
The maximum number of nodes on level I of a binary tree is which of the following? (Root is Level 1)
Option 1 :
Ques 147 : Choose the correct answer
Consider an array on which bubble sort is used. The bubble sort would compare the element A[x] to which of the following elements in a single iteration.
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
36/41 |
10/13/2014 |
|
tech.htm |
|
|
Option 1 : A [x+1] |
Option 2 : A [x+2] |
Option 3 : A [x+2x] |
Option 4 : All of |
|
|
|
|
|
these. |
|
|
|
|
|
|
|
|
|
|
Ques 148 : Choose the correct answer
In an implementation of a linked list, each node contains data and address. Which of the following could the address field possibly contain?
Option 1 : Address of |
Option 2 : It's own |
Option 3 : Address of last |
Option 4 : Address |
next node in sequence |
address |
node |
of first node |
Ques 149 : Choose the correct answer
Surbhi wants to implement a particular data structure using a static array. She uses the concept of circular list to implement the data structure, because this allows her to efficiently use all fields of the array. Which data structure is Surbhi implementing?
Option 1 |
: a stack |
Option 2 : a queue |
Option 3 |
: Binary Tree |
Option 4 |
: None of |
|
|
|
|
|
these |
|
|
|
|
|
|
||
|
|
|
|
|
||
Ques 150 : Choose the correct answer |
|
|
|
|
||
Which of the following is a bad implementation for a queue? |
|
|
||||
Option 1 |
: Circular |
Option 2 : Doubly |
Option 3 |
: Singly linked |
Option 4 |
: Linear |
List |
|
linked list |
List |
|
Static Array |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ques 151 : Choose the correct answer
Which of the following statements are true about a
|
|
Option 3 : it will occupy |
|
Option 1 : it may be |
Option 2 : it must |
same memory space as |
|
that of linear linked list, |
|||
either linear or circular |
contain a header node |
||
both having same number |
|||
|
|
of nodes |
Option 4 : None of these
Ques 152 : Choose the correct answer
Which of the following data structure may give overflow error, even though the current number of element in it is less than its size ?
Option 1 : Queue implemented in a linear array
Option 2 : Queue implemented in a circularly connected array
Option 3 : Stack |
Option 4 : none of |
|
implemented in a linear |
||
these |
||
array |
|
Ques 153 : Choose the correct answer
Number of possible ordered trees with 3 nodes A, B, C is
Option 1 : 16 |
Option 2 : 12 |
Option 3 : 13 |
Option 4 : 14 |
|
|
|
|
|
|
|
|
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
37/41 |
10/13/2014 tech.htm
Ques 154 : Choose the correct answer
The best sorting methods if number of swapping done is the only measure of efficiency is
Option 1 : Bubble sort |
Option 2 : Selection |
Option 3 : Insertion sort |
Option 4 : Quick |
sort |
sort |
Ques 155 : Choose the correct answer
As part of the maintenance work, you are entrusted with the work of rearranging the library books in a shelf in proper order, at the end of each day. The ideal choice will be
Option 1 : bubble sort Option 2 : insertion sort Option 3 : selection sort |
Option 4 : heap |
sort |
|
|
|
|
|
Ques 156 : Choose the correct answer
A hash table can store a maximum of 10 records. Currently there are records in locations 1, 3, 4, 7, 8, 9, 10. The probability of a new record going into location 2, with a hash function resolving collisions by linear probing is
Option 1 |
: 0.6 |
Option 2 |
: 0.1 |
Option 3 |
: 0.2 |
Option 4 |
: 0.5 |
|
|
|
|
|
|||
|
|
|
|
|
|||
Ques 157 : Choose the correct answer |
|
|
|
|
|||
A full binary tree with n leaves contains |
|
|
|
|
|||
Option 1 |
: 2n + 1 |
Option 2 |
: log2 n nodes |
Option 3 |
: 2n - 1 nodes |
Option 4 |
: 2n |
nodes |
|
|
|
|
|
nodes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ques 158 : Choose the correct answer
An array contains the following elements in order: 7 6 12 30 18. Insertion sort is used to sort the array in ascending order. How many times will an insertion be made?
Option 1 : 2 |
Option 2 : 3 |
Option 3 : 4 |
Option 4 : 5 |
|
|
|
|
|
|
|
|
Ques 159 : Choose the correct answer
An array of 5 numbers has the following entries in order: 7 4 5 10 8. Prashant uses selection sort to sort this array in descending order. What will the array contain after two iterations of selection sort?
Option 1 : 10 8 7 5 4 Option 2 : 10 8 5 7 4 |
Option 3 : 8 10 5 7 4 |
Option 4 : None of |
|
these |
|||
|
|
||
|
|
|
|
|
|
|
Ques 160 : Choose the correct answer
Srishti writes a program to find an element in the array A[5] with the following elements in order: 8 30 40 45 70. She runs the program to find a number X. X is found in the first iteration of binary search. What is the value of X?
Option 1 : 40 |
Option 2 : 8 |
Option 3 : 70 |
Option 4 : 30 |
|
|
|
|
|
|
|
|
Ques 161 : Choose the correct answer
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
38/41 |
10/13/2014 |
tech.htm |
The array A has n elements. We want to determine the position of X in the array. We know that X is present in the array A and X can be present at any location in the array with equal probability. How many comparisons will be required on average to find the element X using linear search?
Option 1 : n |
Option 2 : (n+1)/2 |
Option 3 : 2*n |
Option 4 : n^2 |
|
|
|
|
|
|
|
|
Ques 162 : Choose the correct answer
A is an empty stack. The following operations are done on it. PUSH(1)
PUSH(2) POP PUSH(5) PUSH(6) POP
What will the stack contain after these operations. (Top of the stack is underlined)
Option 1 : 5 6 |
Option 2 : 1 5 |
Option 3 : 5 6 |
Option 4 : 1 5 |
|
|
|
|
|
|
|
|
Ques 163 : Choose the correct answer
A stack is implemented as a linear array
function PUSH( top, E, N )
{
if(X)
{
top= top+1 A[top] = E
}
else
{
print "Overflow"
}
return top
}
Fill in the condition X
Option 1 : top< N |
Option 2 : top |
Option 3 : top > 0 |
Option 4 : top > 1 |
|
|
|
|
|
|
|
|
Ques 164 : Choose the correct answer
A stack is implemented as a linear array
function POP( top, N )
{
if(X)
{
top = top - 1
}
else
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
39/41 |
10/13/2014 |
tech.htm |
{
print "Underflow"
}
return top
}
Fill in the condition X
Option 1 : top< |
Option 2 : top |
Option 3 : top>1 |
Option 4 : top >= 0 |
|
|
|
|
|
|
|
|
Ques 165 : Choose the correct answer
Q is an empty queue. The following operations are done on it: ADD 5
ADD 7
ADD 46
DELETE
ADD 13
DELETE
DELETE
ADD 10
What will be the content of Q after these operations. Front is marked by (F) and Rear is marked by (R).
Option 1 : 10(R) 13(F) Option 2 : 5(R) 10(F) Option 3 : 13(R) 10(F) |
Option 4 : 10(R) |
|
5(F) |
|
|
|
|
Ques 166 : Choose the correct answer
A queue is implemented as a (singly linked)
Option 1 : Front |
Option 2 : Rear |
Option 3 : Both |
Option 4 : None of |
|
these |
||||
|
|
|
||
|
|
|
|
|
|
|
|
|
Ques 167 : Choose the correct answer
A stack is implemented as a
|
Option 2 : The node |
Option 3 : The node |
|
Option 1 : No node. It |
containing the first |
containing the element |
Option 4 : None of |
will be empty |
element pushed into the which was pushed just |
these |
|
|
stack. |
before the top element. |
|
|
|
|
|
|
|
|
|
Ques 168 : Choose the correct answer
A queue is implemented by a linear array of size 10 (and not as a circularly connected array). Front and Rear are represented as an index in the array. To add an element, the rear index is incremented and the element is added. To delete an element, the front index is incremented. The following operations are done on an empty queue.
ADD 1; DELETE; ADD 2; ADD 3; ADD 4; DELETE, DELETE
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
40/41 |
10/13/2014 |
tech.htm |
After this set of operations, what is the maximum capacity of the queue?
Option 1 : 6 |
Option 2 : 7 |
Option 3 : 10 |
Option 4 : None of |
|
these |
||||
|
|
|
||
|
|
|
|
|
|
|
|
|
Ques 169 : Choose the correct answer
A queue is implemented as a (singly linked)
Option 1 : It has no |
Option 2 : It has one |
Option 3 : There is an |
Option 4 : None of |
elements |
element |
error |
these |
|
|
|
|
|
|
|
|
Ques 170 : Choose the correct answer
Jaswinder has a book of tickets and wants to store ticket numbers in a data structure. New tickets are added to the end of the booklet. Ticket at the top of the stack is issued to the customer. Which data structure should Jaswinder use to represent the ticket booklet?
Option 1 : Queue |
Option 2 : Stack |
Option 3 : Array |
Option 4 : Graph |
|
|
|
|
|
|
|
|
file:///C:/Users/Lalabhaiya/Desktop/Abhisek/tech.htm |
41/41 |
No comments:
Post a Comment