TYPICAL QUESTIONS & ANSWERS
PART
- I
OBJECTIVE TYPE QUESTIONS
Each
Question carries 2 marks.
Choose
correct or the best alternative in the following:
Q.1 What is the output of the following program?
main ( )
{ int x = 2, y = 5;
if (x < y) return (x = x+y); else
printf (“z1”);
printf(“z2”);
}
(A) z2 (B) z1z2
(C)
Compilation error (D) None of these
Ans: D
There is no compilation error but there will no output because function is returning a value and if statement is true in this case.
Q.2 Choose the correct one
(A) Address operator can not be
applied to register variables
(B) Address operator can be
applied to register variables
(C) Use of register declaration will increase the execution time
(D) None of the above
Ans: D
A register access is much faster than a memory access, keeping the frequently accessed variables in the register will lead to faster execution of programs.
Q.3 What is the following program doing?
main ()
{ int d = 1;
do
printf(“%d\n”, d++);
while (d < = 9);}
(A)
Adding 9 integers (B) Adding integers from 1 to 9
(C) Displaying integers from 1 to 9 (D) None of these
Ans: C
d starting from 1 is incrementing one by one till d=9 so the printf statement is printing numbers from 1 to 9.
Q.4 What is the output of the following program?
main ( )
{ extern int x;
x = 20;
printf(“\n%d”,
x);
}
(A) 0 (B) 20
(C) error (D) garbage value
Ans: C
Output of the given program will be “Linker error-undefined symbol x”. External variables are declared outside a function.
Q.5 If x is one dimensional array, then pick up the correct answer
(A)
*(x + i) is same as
&x[i] (B) *&x[i] is same as x + i
(C) *(x + i) is same as x[i] +1 (D) *(x + i) is same as *x[i]
Ans: A
num[i] is same as *(num+i)
Q.6 Consider the following declaration
int a, *b = &a, **c = &b;
The following program fragment
a = 4;
**c = 5;
(A) does not change the value of a (B) assigns address of c to a
(C) assigns the value of b to a (D) assigns 5 to a
Ans: D
The given statements assigns 5 to a
Q.7 Choose the correct answer
(A)
enum variable can not be
assigned new values
(B)
enum variable can be
compared
(C) enumeration feature increase the power of C
(D) None of the above
Ans: C
The enumerated data types give an opportunity to invent our own data typeand define what value the variable of this data type can take.
Q.8 The content of file will be lost if it is opened in
(A)
w mode (B) w+ mode
(C) a mode (D) a+ mode
Ans: A
When the mode is writing, the contents are deleted and the file is opened as a new file.
Q.9 Consider
the following code segment:
int a[10], *p1, *p2;
p1 = &a[4];
p2
= &a[6];
Which
of the following statements is incorrect w.r.t. pointers?
(A) p1 + 2 (B)
p2 – 2
(C) p2 + p1 (D) p2 – p1
Ans: C
Addition of two pointers is not allowed.
Q.10 The second expression (j – k) in the following expression will be evaluated
(i + 5) && (j – k)
(A) if expression (i + 5) is true.
(B) if expression (i + 5) is false.
(C) irrespective of whether (i + 5) is true or
false.
(D) will not be evaluated in any case.
Ans: A
In a compound logical expression combined with &&, the second expression is evaluated only if first is evaluated in true.
Q.11 In the for statement: for (exp1; exp2;
exp3) { … }
where exp1, exp2 and exp3 are expressions. What is optional?
(A) None of the expressions is optional.
(B) Only exp1 is optional.
(C) Only exp1 and exp3 are optional.
(D) All the expressions are optional.
Ans: D
All the expressions are optional. For (;;) is a valid statement in C.
Q.12 The output of the following code segment will be
char x = ‘B’;
switch (x) {
case ‘A’: printf(“a”);
case ‘B’: printf(“b”);
case ‘C’: printf(“c”);
}
(A) B (B) b
(C) BC (D) bc
Ans: D
Since there is no break statement, all the statement after case’B’ are executed.
Q.13 What will be the output of the following code segment?
main( ) {
char s[10];
strcpy(s, “abc”);
printf(“%d %d”, strlen(s), sizeof(s));
}
(A) 3 10 (B) 3 3
(C) 10 3 (D) 10 10
Ans: A
strlen(s) give the length of the string, that is 3 and sizeof(s) give the size of array s that is 10.
Q.14 Which of the following is the odd one out?
(A) j = j + 1; (B)
j =+ 1;
(C) j++; (D) j += 1;
Ans: B
j=+1 is odd one out as rest all means incrementing the value of variable by 1.
Q.15 Which of the following is true for the statement:
NurseryLand.Nursery.Students
= 10;
(A) The structure
Students is nested within the structure Nursery.
(B) The structure
NurseryLand is nested within the structure Nursery.
(C)
The structure Nursery is nested within the structure
NurseryLand.
(D)
The structure Nursery is nested within the structure
Students.
Ans: C
The structure Nursery is nested within the structure NurseryLand.
Q.16 What will be the output of the following code segment, if any?
myfunc ( struct
test t) {
strcpy(t.s, “world”);
}
main( ) {
struct test {
char s[10]; } t;
strcpy(t.s, “Hello”);
printf(“%s”, t.s);
myfunc(t);
printf(“%s”, t.s);
}
(A)
Hello Hello (B)
world world
(C) Hello world (D) the
program will not compile
Ans: D
The program will not compile because undefined symbol s for myfunc( ) function. Structure should be defined before the main and the function where it is called.
Q.17 If a function is declared as void fn(int *p), then which of the following statements is valid to call function fn?
(A) fn(x) where x is defined
as int x;
(B) fn(x)
where x is defined as int *x;
(C) fn(&x) where x is defined as int
*x;
(D) fn(*x) where x is defined as int
*x;
Ans: B
Function void fn(int *p) needs pointer to int as argument. When x is defined as int *x, then x is pointer to integer and not *x.
Q.18 What is the following function computing? Assume a and b are positive integers.
int fn( int a, int b) {
if (b == 0)
return b;
else
return (a * fn(a, b - 1));
}
(A) Output will be 0 always (B) Output will always be b
(C) Computing ab (D) Computing a + b
Ans: A
The output is always be 0 because b is decremented in recursive function fn each time by 1 till the terminating condition b==0 where it will return 0.
Q.19 What is the output
of the following C program?
# include
<stdio.h>
main ( )
{
int a, b=0;
static int c [10]={1,2,3,4,5,6,7,8,9,0};
for (a=0; a<10;+ + a)
if ((c[a]%2)= = 0) b+ = c [a];
printf (“%d”, b);
}
(A) 20 (B)
25
(C) 45 (D) 90
Ans: A
printf statement will print b which is sum of the those values from array c which get divided by 2, that is 2+4+6+8=20.
Q.20 If a, b and c are integer variables with the values a=8, b=3 and c=-5. Then what is the value of the arithmetic expression:
2 * b + 3 * (a-c)
(A) 45 (B) 6
(C) -16 (D) -1
Ans: A
the value of the arithmetic expression is 45 as 2*3+3*(8—5)=6+3*13=6+39=45
Q.21 A global variable is a variable
(A) declared in the main ( ) function.
(B) declared in any function other than the main ( ) function.
(C) declared outside the body of every function.
(D) declared any where in the C program.
Ans: C
A global variable is declared outside the body of every function.
Q.22 main ( ) is an example of
(A) library function (B) user defined function
(C) header (D) statement
Ans: A
main() is a special function used by C system to tell the computer where the program starts.
Q.23 While incrementing a pointer, its value gets increased by the length of the data type to which it points. This length is called
(A) scale factor (B) length factor
(C) pointer factor (D) increment factor
Ans: D
While incrementing a pointer, its value gets increased by the length of the data type to which it points.
Q.24 The first digit of a decimal constant must be
(A) a zero (B) a non zero number
(C) a negative number (D)
an integer
Ans: D
Decimal constants consist of a set of digit, 0 to 9, preceded by an optional – or + sign.
Q.25 What is the output of the following statement:
printf (“%-3d”,12345);
(A) 1 2 3 (B) -1 2 3
(C) 1 2 3 4 5 (D) 12
Ans: C
printf statement would print 12345.
Q.26 A single character input from the keyboard can be obtained by using the function.
(A) printf ( ) (B)
scanf ( )
(C) putchar ( ) (D) getchar
( )
Ans: D
Reading a single character can be done by using the function getchar( ).
Q.27 The function ftell ( )
(A) reads a character from a file
(B) reads an integer from
a file
(C) gives the current
position in the file
(D) sets the position to
the beginning of the file.
Ans: C
ftell( ) takes a file pointer and returns a number of type long, that corresponds to the current position.
Q.28 If the variables i, j and
k are assigned the values 5,3 and 2 respectively, then the expression i = j + ( k + + =
6 ) + 7
(A) gives an error message (B) assigns a value 16 to i
(C) assigns a value 18 to i (D) assigns a value 19 to i
Ans: A
It gives an error message-Lvalue required.
Q.29 If an integer
needs two bytes of storage, then the maximum value of a signed integer is
(A) 216-1 (B) 215-1
(C) 216 (D) 215
Ans: B
If we use a 16 bit word length, the size of the integer value is limited to the range
-215 to 215-1
Q.30 Literal means
(A) a string (B) a string constant
(C) a character (D) an alphabet
Ans: B
Literal means a string constant.
Q.31 If ‘y’ is of integer type then the expressions
(A) must yield the same value.
(B) must yield different values.
(C) may or may not yield the same value.
(D) none of the above.
Ans: C
The expression may or may not yield the same value.
Q.32 In the following code fragment
int x, y = 2, z, a;
x=(y*=2) + (z=a=y);
printf (‘%d’,x);
(A) prints 8
(B) prints 6
(C) prints 6 or 8
depending on the compiler
(D) is syntactically wrong
Ans: A
It will print 8 because x=(y*=2)+(z=a=y)=4+4=8.
Q.33 A possible output of the following program fragment is
for
(i=getchar();; i=get.char())
if (i==‘x’) break;
else putchar(i);
(A) mi (B) mix
(C) mixx (D) none of the above
Ans: D
None of the above as it is wrong syntax.
Q.34 In a for loop, if the condition is missing, then,
(A) It is assumed to be
present and taken to be false.
(B)
It is assumed to be present and taken to be true.
(C)
It results in a syntax error.
(D) Execution will be terminated abruptly.
Ans: B
Q.35 If storage class is missing in the array definition, by default it will be taken to be
(A) automatic
(B) external
(C)
static
(D)
either automatic or external depending on the place of
occurrence.
Ans: A
A variable declared inside inside a function without storage class specification is, by default, an automatic variable.
Q.36 The maximum number of dimensions an array can have in C is
(A) 3 (B)
4
(C) 5 (D)
compiler dependent
Ans: D
C allows arrays of three or more dimensions. The exact limit is determined by the compiler.
Q.37 puts(argv[0]);
(A) prints the name of the source code file.
(B) prints argv.
(C) prints the number of
command line arguments.
(D) prints the name of
the executable code file.
Ans: D
argv[0] represent the filename where the executable code of the program is stored.
Q.38 printf(“%–10s”, “ABDUL”); displays
![]()
(A) ABDULbbbbb (B) bbbbbABDUL
![]()
(C) ABDULbbbbbbbbbb (D)
bbbbbbbbbbABDUL
Ans: A
-10s will print ABDUL in 10 space ABDUL followed by 5 blank space.
Q.39 Which amongst the following expression uses bitwise operator?
(A) a++ (B) !a>5
(C) a|b (D) a!=b
Ans: C
| is bitwise OR.
Q.40 The output of the following program is
main( )
{ float
y;
y=198.7361;
printf(“%7.2f”, y);
}
|
(A) |
1 |
9 |
8 |
. |
7 |
3 |
6 |
(B) |
1 |
9 |
8 |
. |
7 |
3 |
|
|
(C) |
|
1 |
9 |
8 |
. |
7 |
4 |
(D) |
1 |
9 |
8 |
. |
7 |
4 |
|
Ans: C
The printf statement is giving formatted output till two places of decimal.
Q.41 Which is not dynamic memory
allocation function?
(A) malloc (B)
free
(C)
alloc (D) calloc
Ans: C
Three dynamic memory allocation functions are: malloc, calloc and free
Q.42 Which header file is used for screen handling function:-
(A)
IO.H (B) STDLIB.H
(C) CONIO.H (D) STDIO.H
Ans: D
The header file stdio.h contains definitions of constants,macros and types, along with function declarations for standard I/O functions.
Q.43 Choose the directive that is used to remove previously defined definition of the macro name that follows it -
(A) # remdef (B) # pragma
(C) # undef (D) # define
Ans: C
The preprocessor directive #undef OKAY would cause the definition of OKAY to be removed from the system.
Q.44 The output of the following is
x = ‘a’;
printf(“%d”, x);
(A) ‘a’ (B)
a
(C) 97 (D) None of the above
Ans: C
The printf statement is printing ascii value of a, that is 97.
Q.45 Consider the following statement
int j, k, p;
float q, r, a;
a = j/k;
p=q/r;
If q=7.2, r=20, j=3, k=2
The value of a and p is
(A)
a=1.5, p=3.6 (B) a=2, p=3
(C) a=1.5, p=4 (D) a=1, p=3
Ans: C
a=3/2=1.5 and p=q/r=7.2/2=3.6 is rounded off to 4.
Q.46 Choose the function that returns remainder of x/y -
(A) remainder( ) (B) mod(
)
(C) modulus( ) (D)
rem( )
Ans: C
modulus( ) function produces the reminder of an integer division.
Q.47 What is the output of following program:-
int q, *p, n;
q = 176; If the address of q is 2801
p = &q; and p is 2600
n = *p;
printf(“%d”, n);
(A) 2801 (B)
176
(C) 2600 (D) None of the above
Ans: B
n is assigned a the value which is present at the address of q and that value is 176.
Q.48 Consider the following statements-
x = 5;
y = x >3 ? 10
: 20;
The value of y is
(A) 10 (B) 20
(C) 5 (D) 3
Ans: A
Since x=5 is greater than 3 so y is assigned value 10. It is equivalent to if-else statements.
Q.49 Determine which of the following is an invalid character constant.
(A) ‘\a’ (B) ‘T’
(C) ‘\0’ (D) ‘/n’
Ans: D
newline character constant is “\n” not “/n”.
Q.50 What is the name of built-in function for finding square roots?
(A) square(x) (B) sqr(x)
(C) sqrt(x) (D) No built-in function
Ans: C
sqrt(x) is a built-in function for finding square roots.
Q.51 What is the output of following
statement?
for(i=1; i<4;
i++)
printf(“%d”,(i%2)
? i : 2*i);
(A) 1
4 3 (B) 1
2 3
(C) 2
4 6 (D) 2 2 6
Ans: A
for i=1, (i%2) is true so the statement will print 1; for for i=2, (i%2) is false so the statement will print 2*i=2*2=4; for for i=3, (i%2) is again true so the statement will print 3; for i=4, the statement is out from the loop.
Q.52 Which of the following statement is true about a function?
(A) An invoking function must pass arguments to the
invoked function.
(B)
Every function returns a value to the invoker.
(C) A
function may contain more than one return statement.
(D) Every
function must be defined in its own separate file.
Ans: A
An invoking function must pass arguments to the invoked function.
Q.53 What is the output of the following program?
main( )
{
int i=4, z=12;
if(i=5 || z>50)
printf(“hello”);
else
printf(“hye”);
}
(A) hello (B)
hye
(C) syntax error (D) hellohye
Ans: A
i=5 will assign value 5 to i so the if statement (i=5||z>50) is true so “printf” statement will print hello.
Q.54 For implementing recursive function the
data structure used is:
(A) Queue (B)
Stack
(C) Linked List (D) Tree
Ans: B
For implementing recursive function, stack is used as a data structure.
Q.55 The size of array int a[5]={1,2} is
(A) 4 (B) 12
(C) 10 (D) 6
Ans: C
The size of int array is 2*5=10 bytes as int takes 2 bytes of storage.
Q.56 Which of the following is not an escape
sequence?
(A) \n (B)
\r
(C) \’ (D)
\p
Ans: D
\p is not an escape sequence.
Q.57 The output of the following statements is
char ch[6]={‘e’, ‘n’, ‘d’,
‘\0’, ‘p’};
printf(“%s”, ch);
(A) endp (B)
end0p
(C) end (D) error
Ans: C
printf statement will print end because string is terminated at “\0” and in array after d, we have null character.
Q.58 How many times the following code prints the string “hello”.
for(i=1; i<=1000; i++);
printf(“hello”);
(A) 1 (B) 1000
(C) Zero (D) Syntax error
Ans: A
The “for” loop is terminated by a semicolon so the next statement is execute that is printing hello.
Q.59 Find the invalid identifiers from the following:-
(i) nA (ii) 2nd (iii) ROLL NO
(iv) case
(A) (i),
(ii) and (iv) (B) (i) and (iii)
(C) (ii), (iii) and (iv) (D) (ii), (i) and (iii)
Ans: C
Identifier cannot start with a digit; it cannot have a space and case is a keyword.
Q.60 The void type is used for
(A) Returning the
value (B) creating generic pointers
(C) Creating functions (D) Avoid error
Ans: B
The void type is used to create generic pointers.
Q.61 The valid octal constants from
the following
(i) 0245 (ii) 0387 (iii) 04.32 (iv) –0467
(A) (i) and (ii) (B) (iii) and (iv)
(C)
(ii) and (iii) (D) (i) and (iv)
Ans: D
(i) and (iv) are valid octal constants.
Q.62 The variable that are declared outside all the functions are called ______.
(A) Local variable (B) Global variable
(C) Auto variable (D) None of
the above
Ans: B
The variables that are declared outside all functions are called global variable.
Q.63 Consider the following statements:-
int x = 6, y=8,
z, w;
y = x++;
z = ++x;
The value of
x,y,z by calculating the above expressions are:-
(A) y=8, z=8, x=6 (B) y=6, x=8, z=8
(C) y=9, z=7, x=8 (D)
y=7, x=8, z=7
Ans: B
y is assigned value of x that is 6, then x in incremented that is value of x=7, z is assigned value of x after incrementing that is z =8 so value of x =8.
Q.64 To declare an array S that
holds a 5-character string, you would write
(A) char
S[5] (B)
String S[5]
(C) char S[6] (D) String S[6]
Ans: A
A string is nothing but a char array.
Q.65 The function used to read a character from a
file that has been opened in read mode is
(A) putc (B) getc
(C) getchar (D) putchar
Ans: B
getc is used to read a character from a file that has been opened in read mode.
Q.66 The function that allocates
requested size of bytes and returns a pointer to the first byte of the
allocated space is -
(A) realloc (B)
malloc
(C) calloc (D)
none of the above
Ans: B
malloc allocates requested size of bytes and returns a pointer to the first byte of the allocated space.
Q.67 The constructed datatype of C is known as
(A) Pointers (B)
String
(C) Structure (D) Array
Ans: C
Structure is a constructed datatype of C
Q.68 The postfix form
of the following infix notation is :
(A)
(B)
![]()
(C)
(D)
Ans: (A)
Q.69 The
number of nodes in a complete binary tree of depth d (with root at depth 0) is
(A)
(B)
![]()
(C)
(D) ![]()
Ans: (B)
Q.70 The
average case of quick sort has order
(A)
(B)
![]()
(C)
(D) ![]()
Ans: (C)
Q.71
Inorder to get the information stored in a BST in the descending order, one
should traverse it in which of the following order?
(A) left, root, right (B) root, left, right
(C) right, root, left (D) right, left, root
Ans:
(C)
Q.72 Every
internal node in a B-tree of minimum degree 2 can have
(A)
2, 3 or 4 children (B) 1, 2 or 3 children
(C) 2, 4 or 6 children (D) 0, 2 or 4 children
Ans: (B)
Q.73 Which
sorting algorithm is the best if the list is already in order?
(A) Quick sort (B) Merge sort
(C) Insertion sort (D) Heap sort
Ans: (C)
Q.74 In _________ the difference between the
height of the left sub tree and height of right sub tree, for each node, is not
more than one
(A)
BST (B) Complete Binary Tree
(C) AVL-tree (D) B-tree
Ans: (C)
Q.75 The number of comparisons required to sort 5
numbers in ascending order using bubble sort
is
(A)
7 (B) 6
(C) 10 (D) 5
Ans: (C)
Q.76 The complexity of adding
two matrices of order m*n is
(A) m + n (B) mn
(C) max(m, n) (D) min(m, n)
Ans: (B)
Q.77 The
second largest number from a set of n distinct numbers can be found in
(A) O(n) (B) O(2n)
(C)
(D) O(log n)
Ans: (A)
Q.78 If
the inorder and preorder traversal of a binary tree are D,B,F,E,G,H,A,C and A,B,D,E,F,G,H,C respectively then the
postorder traversal of that tree is
(A)
D,F,G,A,B,C,H,E (B)
F,H,D,G,E,B,C,A
(C) C,G,H ,F,E,D,B,A (D) D,F,H,G,E,B,C,A
Ans: (D)
Q.79 In a binary
tree, the number of terminal or leaf nodes is 10. The number of nodes with
two children is
(A) 9 (B) 11
(C) 15 (D) 20
Ans: (A)
Q.80 Which amongst
the following cannot be a balance factor of any node of an AVL tree?
(A)
1 (B) 0
(C) 2 (D) –1
Ans: (C)
Q.81 How many distinct
binary search trees can be formed which contains the integers 1, 2, 3?
(A) 6 (B) 5
(C) 4 (D) 3
Ans: (B)
Q.82 The
sort which inserts each elements A(K) into proper position in the previously
sorted sub array A(1), ..., A(K–1)
(A)
Insertion sort (B) Radix sort
(C) Merge sort (D) Bubble sort
Ans: (A)
Q.83 Direct or random access of elements is
not possible in
(A)
Linked list (B) Array
(C) String (D) None of these
Ans: (A)
Q.84 Level
of any node of a tree is
(A)
Height of its left subtree minus height of its right subtree
(B)
Height of its right subtree minus height of its left subtree
(C)
Its distance from the root
(D) None of these
Ans: (C)
Q.85 A
desirable choice for the partitioning element in quick sort is
(A)
First element of the list
(B)
Last element of the
list
(C) Randomly chosen
element of the list
(D)
Median of the list
Ans: (A)
Q.86 lg (n!) =____________
(A) O (n) (B) O (lg n)
(C) O (n2) (D) O (n lg n)
Ans: (D)
n!=n(n-1)(n-2)-----3X2X1
≥(n/2)n/2
log n!≥ n/2logn/2
≥ n/2(logn-log2)
≥ n/2 (log n-1)
≤ n log n
= O(n
log n)
Q.87 The result of evaluating the following postfix expression is
5, 7, 9, *,
+, 4, 9, 3, /, +, -
(A)
50 (B)
65
(C) 61 (D) 69
Ans: (C)
Q.88 A graph with n vertices will
definitely have a parallel edge or self loop if the total number of edges are
(A)
more than n (B)
more than n+1
(C) more than (n+1)/2 (D) more than n(n-1)/2
Ans: (D)
Q.89 Out of the following, the slowest sorting procedure is
(A) Quick Sort (B) Heap Sort
(C) Shell Sort (D) Bubble Sort
Ans: (D)
Q.90 In ________, it is possible to traverse a tree without using stacks either implicitly or explicitly.
(A)
Threaded binary trees.
(B) AVL Tree
(C) B+ tree
(D) Heap
Ans: (C)
Q.91 The order of a B-Tree with 2, 3, 4 or 5 children in every internal node is
(A)
2 (B) 3
(C) 4 (D) 5
Ans: (C)
Q.92 The number of nodes that have no successors in a complete binary tree of depth 4 is
(A) 0 (B) 8
(C) 16 (D) 4
Ans: (B)
Q.93 One can make an exact replica of a Binary Search Tree by traversing it in
(A)
Inorder (B)
Preorder
(C) Postorder (D) Any
order
Ans: (B)
Q.94 A complete Binary Tree with 15 nodes contains________edges
(A) 15 (B) 30
(C) 14 (D) 16
Ans: (C)
Q.95 The minimum number of comparisons required to find the largest number from 4 different numbers are
(A) 4 (B) 3
(C) 5 (D) 6
Ans: (B)
Q.96 An infix expression
can be converted to a postfix expression using a
(A) Stack (B)
Queue
(C) Dequeue (D) None of these
Ans: (A)
Q.97 A data structure in which an element is added and removed only from
one end, is known as
(A)
Queue (B)
Stack
(C) In-built structure (D)
None of the above
Ans: (B)
Q.98 A complete binary
tree with the property that the value of each node is at least as
large as the values of its children is known as
(A) Binary Search Tree. (B) AVL Tree.
(C) Heap. (D) Threaded Binary Tree.
Ans: (C)
Q.99 A sorting algorithm is stable if
(A)
its time complexity
is constant irrespective of the nature of input.
(B)
preserves the original order of records with equal keys.
(C)
its space complexity is constant irrespective of the nature
of input.
(D) it sorts any volume
of data in a constant time.
Ans: (B)
Q.100 A tree in which, for every node, the difference between the height of its left subtree
and right subtree is not more than one is
(A)
AVL Tree. (B) Complete Binary Tree.
(C) B – Tree. (D)
Tree.
Ans: (A)
Q.101 The data structure needed to convert a recursion to an iterative procedure is
(A) Queue. (B) Graph.
(C) Stack. (D) Tree.
Ans: (C)
Q.102 A
binary tree stored using linked representation can be converted to its mirror
image by traversing it in
(A) Inorder. (B) Preorder.
(C) Postorder. (D) Any order.
Ans: (B)
Q.103 The prefix form of an infix expression A+B-C*D is
(A)
+
(C)
-+A B * C D. (D) - + *ABCD.
Ans: (C)
Q.104 The number of edges in a simple, n-vertex, complete graph is
(A) n*(n-2). (B) n*(n-1).
(C) n*(n-1)/2. (D) n*(n-1)*(n-2)
Ans: (C)
Q.105 The
largest and the second largest number from a set of n distinct numbers can be
found in
(A)
O (n). (B) O (2n).
(C) O
. (D) O (log n).
Ans:
(A)
Q.106
To implement Sparse matrix dynamically,
the following data structure is used
(A) Trees (B)
Graphs
(C) Priority Queues (D) Linked List
Ans: (D)
Q.107 The depth dn, of complete binary tree of n
nodes, where nodes are labeled from 1 to n with root as node 1 and last leaf node as node n is
(A)
(B)
![]()
(C)
(D) ![]()
Ans: (C)
Q.108 The
balance factor for an AVL tree is either
(A)
0,1 or –1 (B)
–2,–1 or 0
(C) 0,1 or 2 (D) All the above
Ans: (A)
Q.109 Applications of Linked List are
(A) Simulation , event driven systems
(B) Postfix and prefix manipulations
(C) Dictionary systems, polynomial manipulations
(D) Fixed block storage allocation, garbage
collection
Ans: (D)
Q.110 AVL trees have LL,
LR, RR, RL rotations to balance the tree
to maintain the balance factor (LR :
Insert node in Right sub tree of Left sub tree of node A, etc). Among rotations the following are
single and double rotations
(A)
LL, RL and LR, RR (B) LL, RR and LR, RL
(C) LR, RR and LL, RL (D) LR, RL and LR, RL
Ans: (B)
Q.111 Hashing
collision resolution techniques are
(A) Huffman coding, linear hashing (B)
Bucket addressing, Huffman coding
(C) Chaining, Huffman coding (D) Chaining, Bucket addressing
Ans: (D)
Q.112 The
running time of the following sorting algorithm
depends on whether the partitioning is balanced or unbalanced
(A)
Insertion sort (B) Selection sort
(C) Quick sort (D) Merge sort
Ans: (C)
Q.113 Graphs
are represented using
(A)
Adjacency tree (B)
Adjacency linked list
(C) Adjacency graph (D)
Adjacency queue
Ans: (B)
Q.114 The average case complexity of Insertion
Sort is
(A)
O(2n) (B) O(n3)
(C) O(n2) (D) O(2n)
Ans:
(C)
Q.115 Infinite recursion leads to
(A)
Overflow of
run-time stack (B)
Underflow of registers usage
(C) Overflow
of I/O cycles (D)
Underflow of run-time stack
Ans: (A)
Q.116 The number of unused pointers in
a complete binary tree of depth 5 is
(A) 4 (B)
8
(C) 16 (D) 32
Ans: (C)
Q.117 The running time for creating a heap of size n is
(A)
O (n) (B)
O (log n)
(C) O (n log n) (D) O (n2)
Ans: (C)
Q.118 What would be returned by the following recursive function after we call test (0, 3)
int test (int a,
int b)
{
if (a==b) return (1);
else if (a>b) return(0);
else return (a+test(a+1, b));
}
(A) 1 (B) 2
(C)
3 (D) 4
Ans: (D)
Q.119 The extra key inserted at the end of the array is called a
(A)
End Key (B) Stop Key
(C) Sentinel (D) Transposition
Ans: (C)
Q.120 Which of the following operations is performed more efficiently by doubly linked list than by singly linked list
(A)
Deleting a node whose location is given.
(B)
Searching of an unsorted list for a given item.
(C)
Inserting a new node after node whose location is given.
(D)
Traversing the list to process each node.
Ans: (A)
Q.121 One can determine whether a Binary tree is a Binary Search Tree by traversing it in
(A) Preorder (B) Inorder
(C) Postorder (D) Any of the three orders
Ans: (B)
Q.122 The spanning tree of connected graph with 10 vertices contains
(A) 9 edges (B)
11 edges
(C) 10 edges (D) 9
vertices
Ans: (A)
Q.123 A sorted file contains 16 items. Using binary search, the maximum number of comparisons to search for an item in this file is
(A) 15 (B) 8
(C) 1 (D) 4
Ans: (D)
Q.12 4 One can determine whether an infix expression has balanced parenthesis or not by using
(A) Array (B) Queue
(C) Stack (D) Tree
Ans: (C)
Q.12 5 The average number of key comparisons done
in successful sequential search in a list of
length n is
(A) log n (B)
(n-1)/2
(C) n/2 (D) (n+1)/2
Ans:
(D)
Q.12 6 The maximum number of nodes in a binary
tree of depth 5 is
(A)
31 (B)
16
(C) 32 (D) 15
Ans: (A)
Q.127 n elements of a Queue are to be reversed using another queue. The
number of “ADD” and “REMOVE” operations required to do so is
(A)
2*n (B)
4*n
(C) n (D) The task cannot be accomplished
Ans: (D)
Q.128 A complete binary tree with n leaf nodes has
(A) n+1 nodes (B) 2n-1 nodes
(C) 2n+1 nodes (D) n(n-1)/2 nodes
Ans: (B)
Q.129 A binary tree can be converted in to its mirror image by traversing it in
(A) Inorder (B) Preorder
(C) Postorder (D) Anyorder
Ans: (B)
Q.130 One can convert an infix expression to a postfix expression using a
(A) stack (B) Queue
(C) Deque (D) none of these
Ans: (A)
Q.131 Which of the following types of expressions do not require precedence rules for evaluation?
(A)
fully parenthesised infix expression
(B)
postfix expression
(C)
partially parenthesised infix expression
(D)
more than one of the above
Ans: (A)
Q.132 Overflow condition in linked list may occur when attempting to_____
(A)
Create a node when free space pool is empty.
(B)
Traverse the nodes when free space pool is empty.
(C)
Create a node when linked list is empty.
(D)
None of these.
Ans: (A)
Q.133 Linked lists are not suitable data structures for which one of the following problems
(A) insertion sort (B) binary search
(C)