0% found this document useful (0 votes)
32K views

Fds Se Comp Techvines

This document contains 35 multiple choice questions about C programming fundamentals and data structures. The questions cover topics like variable naming rules, operators, precedence and associativity, conditional statements, loops, functions, preprocessor directives, and more. Each question is followed by 4 possible answer choices with one correct answer. This quiz can help test and improve one's understanding of basic C programming concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32K views

Fds Se Comp Techvines

This document contains 35 multiple choice questions about C programming fundamentals and data structures. The questions cover topics like variable naming rules, operators, precedence and associativity, conditional statements, loops, functions, preprocessor directives, and more. Each question is followed by 4 possible answer choices with one correct answer. This quiz can help test and improve one's understanding of basic C programming concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 196

JOIN OUR TELEGRAM COMMUNITY - TECHVINES CODERS UNION

Click here to join- https://t.me/Techvines_Coders_Union


FUNDAMENTALS OF DATA STRUCTURE SE COMP

Multiple Choice Questions

Unit-1

1. Which of the following is not a valid variable name declaration?


a) int _a3;
b) int a_3;
c) int 3_a;
d) int _3a
Answer:c

2. Variable names beginning with underscore is not encouraged. Why?


a) It is not standardized
b) To avoid conflicts since assemblers and loaders use such names
c) To avoid conflicts since library routines use such names
d) To avoid conflicts with environment variables of an operating system
Answer:c

3. All keywords in C are in


a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None
Answer:a

4. Variable name resolving (number of significant characters for uniqueness of variable) depends
on
a) Compiler and linker implementations
b) Assemblers and loaders implementations
c) C language
d) None
Answer:a

5. Which of the following is not a valid C variable name?


a) int number;
b) float rate;
c) int variable_count;
d) int $main;
Answer:d

6. Which of the following is true for variable names in C?


a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length
Answer:c

7. What is the output of this C code?


#include <stdio.h>
int main()
{
int c = 2 ^ 3;
printf("%d\n", c);
}

a) 1
b) 8
c) 9
d) 0
Answer: a

8. What is the output of this C code?

#include <stdio.h>
int main()
{
unsigned int a = 10;
a = ~a;
printf("%d\n", a);
}

a) -9
b) -10
c) -11
d) 10
Answer:c

9. What is the output of this C code?

#include <stdio.h>
int main()
{
if (7 & 8)
printf("Honesty");
if ((~7 & 0x000f) == 8)
printf("is the best policy\n");
}

a) Honesty is the best policy


b) Honesty
c) is the best policy
d) No output
Answer:c

10. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 2;
if (a >> 1)
printf("%d\n", a);
}

a) 0
b) 1
c) 2
d) No Output.
Answer:c

11. Comment on the output of this C code?

#include <stdio.h>
int main()
{
int i, n, a = 4;
scanf("%d", &n);
for (i = 0; i < n; i++)
a = a * 2;
}

a) Logical Shift left


b) No output
c) Arithmetic Shift right
d) bitwise exclusive OR
Answer:b

12. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 97;
int y = sizeof(x++);
printf("x is %d", x);
}

a) x is 97
b) x is 98
c) x is 99
d) Run time error
Answer:a

13. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 4, y, z;
y = --x;
z = x--;
printf("%d%d%d", x, y, z);
}

a) 3 2 3
b) 2 2 3
c) 3 2 2
d) 2 3 3
Answer:d

14. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 4;
int *p = &x;
int *k = p++;
int r = p - k;
printf("%d", r);
}

a) 4
b) 8
c) 1
d) Run time error
Answer:c

15. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = (y++) ? y == 1 && x : 0;
printf("%d\n", z);
return 0;
}
a) 0
b) 1
c) Undefined behaviour
d) Compile time error
Answer:a

16. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1;
int y = x == 1 ? getchar(): 2;
printf("%d\n", y);
}

a) Compile time error


b) Whatever character getchar function returns
c) Ascii value of character getchar function returns
d) 2
Answer:c

17. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1;
short int i = 2;
float f = 3;
if (sizeof((x == 2) ? f : i) == sizeof(float))
printf("float\n");
else if (sizeof((x == 2) ? f : i) == sizeof(short int))
printf("short int\n");
}

a) float
b) short int
c) Undefined behaviour
d) Compile time error
Answer:a

18. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 2;
int b = 0;
int y = (b == 0) ? a :(a > b) ? (b = 1): a;
printf("%d\n", y);
}

a) Compile time error


b) 1
c) 2
d) Undefined behaviour
Answer:c

19. What is the output of this C code?

#include <stdio.h>
int main()
{
int y = 1, x = 0;
int l = (y++, x++) ? y : x;
printf("%d\n", l);
}

a) 1
b) 2
c) Compile time error
d) Undefined behaviour
Answer:a

19. Comment on the output of this C code?

#include <stdio.h>
void main()
{
int k = 8;
int m = 7;
int z = k < m ? k = m : m++;
printf("%d", z);
}

a) Run time error


b) 7
c) 8

d) Depends on compiler
Answer:b

20. The code snippet below produces

#include <stdio.h>
void main()
{
1 < 2 ? return 1 : return 2;
}
a) returns 1
b) returns 2
c) Varies
d) Compile time error
Answer:d

21. What is the difference between the following 2 codes?

#include <stdio.h> //Program 1


int main()
{
int d, a = 1, b = 2;
d = a++ + ++b;
printf("%d %d %d", d, a, b);
}
#include <stdio.h> //Program 2
int main()
{
int d, a = 1, b = 2;
d = a++ + ++b;
printf("%d %d %d", d, a, b);
}

a) No difference as space doesn’t make any difference, values of a, b, d are same in both the
case
b) No difference as space doesn’t make any difference, values of a, b, d are different
c) Program 1 has syntax error, program 2 is not
d) Program 2 has syntax error, program 1 is not
b) Answer:a

22. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 1, c;
c = a++ + b;
printf("%d, %d", a, b);
}

a) a = 1, b = 1
b) a = 2, b = 1
c) a = 1, b = 2
d) a = 2, b = 2
Answer:b

23. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 1, d = 1;
printf("%d, %d, %d", ++a + ++a+a++, a++ + ++b, ++d + d++ + a++);
}

a) 15, 4, 5
b) 9, 6, 9
c) 9, 3, 5
d) 6, 4, 6
Answer:a

24. For which of the following, “PI++;” code will fail?


a) #define PI 3.14
b) char *PI = “A”;
c) float PI = 3.14;
d) Both (A) and (B)
Answer:a

25. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 10, b = 10;
if (a = 5)
b--;
printf("%d, %d", a, b--);
}

a) a = 10, b = 9
b) a = 10, b = 8
c) a = 5, b = 9
d) a = 5, b = 8
Answer:c

26. What is the output of this C code?

#include <stdio.h>
int main()
{
int i = 0;
int j = i++ + i;
printf("%d\n", j);
}

a) 0
b) 1
c) 2
d) Compile time error
Answer:a
27. What is the output of this C code?

#include <stdio.h>
int main()
{
int i = 2;
int j = ++i + i;
printf("%d\n", j);
}

a) 6
b) 5
c) 4
d) Compile time error
Answer:a

28. Comment on the output of this C code?

#include <stdio.h>
int main()
{
int i = 2;
int i = i++ + i;
printf("%d\n", i);
}

a) = operator is not a sequence point


b) ++ operator may return value with or without side effects
c) it can be evaluated as (i++)+i or i+(++i)
d) Both a and b
Answer:a

29. #include is called


a) Preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned
Answer:a

30. C preprocessors can have compiler specific features.


a) true
b) false
c) Depends on the standard
d) Depends on the platform
Answer:a
31. C preprocessor is conceptually the first step during compilation
a) true
b) false
c) Depends on the compiler
d) Depends on the standard
Answer:a

32. Preprocessor feature that supply line numbers and filenames to compiler is called?
a) Selective inclusion
b) macro substitution
c) Concatenation
d) Line control
Answer:d

33. #include are _______ files and #include “somefile.h” ________ files.
a) Library, Library
b) Library, user-created header
c) User-created header, library
d) They can include all types of file
Answer:d

34. A preprocessor is a program


a) That processes its input data to produce output that is used as input to another program
b) That is nothing but a loader
c) That links various source files
d) All of the mentioned
Answer:a

35.The sequence of allocation and deletion of variables for the following code is.

#include <stdio.h>
int main()
{
int a;
{
int b;
}
}

a) a->b, a->b
b) a->b, b->a
c) b->a, a->b
d) b->a, b->a
Answer:b
42. Array sizes are optional during array declaration by using ______ keyword.
a) auto
b) static
c) extern
d) register

43. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 3;
{
x = 4;
printf("%d", x);
}
}

a) 4
b) 3
c) 0
d) Undefined
Answer:a

44. What is the output of this C code?

#include <stdio.h>
int x = 5;
void main()
{
int x = 3;
m();
printf("%d", x);
}
void m()
{
x = 8;
n();
}
void n()
{
printf("%d", x);
}

a) 8 3
b) 3 8
c) 8 5
d) 5 3
Answer:a
45. What is the output of this C code?

#include <stdio.h>
int x;
void main()
{
m();
printf("%d", x);
}
void m()
{
x = 4;
}

a) 0
b) 4
c) Compile time error
d) Undefined
Answer:b

46. What is the output of this C code?

#include <stdio.h>
static int x = 5;
void main()
{
int x = 9;
{
x = 4;
}
printf("%d", x);
}

a) 9
b) 5
c) 4
d) 0
Answer:c

47. What is the output of this C code?

#include <stdio.h>
void main()
{
{
int x = 8;
}
printf("%d", x);
}

a) 8
b) 0
c) Undefined
d) Compile time error
Answer:d

48.What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 1, y = 0, z = 5;
int a = x && y || z++;
printf("%d", z);
}

a) 6
b) 5
c) 0
d) Varies
Answer:a

49. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 1, y = 0, z = 5;
int a = x && y && z++;
printf("%d", z);
}

a) 6
b) 5
c) 0
d) Varies
50. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1, y = 0, z = 3;
x > y ? printf("%d", z) : return z;
}

a) 3
b) 1
c) Compile time error
d) Run time error
51. What is the output of this C code(when 1 is entered)?

#include <stdio.h>
void main()
{
double ch;
printf("enter a value btw 1 to 2:");
scanf("%lf", &ch);
switch (ch)
{
case 1:
printf("1");
break;
case 2:
printf("2");
break;
}
}

a) Compile time error


b) 1
c) 2
d) Varies
Answer:a

52. What is the output of this C code(When 1 is entered)?

#include <stdio.h>
void main()
{
char *ch;
printf("enter a value btw 1 to 3:");
scanf("%s", ch);
switch (ch)
{
case "1":
printf("1");
break;
case "2":
printf("2");
break;
}
}

a) 1
b) Compile time error
c) 2
d) Run time error
Answer:b

53. What is the output of this C code(When 1 is entered)?

#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf("1\n");
default:
printf("2\n");
}
}

a) 1
b) 2
c) 1 2
d) Run time error
Answer:c

54. What is the output of this C code(When 2 is entered)?

#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf("1\n");
break;
printf("hi");
default:
printf("2\n");
}
}

a) 1
b) hi 2
c) Run time error
d) 2
Answer:d

55. What is the output of this C code(When 1 is entered)?

#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch, ch + 1)
{
case 1:
printf("1\n");
break;
case 2:
printf("2");
break;
}
}

a) 1
b) 2
c) 3
d) Run time error
Answer:b

56. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 1;
switch (a)
{
case a*b:
printf("yes ");
case a-b:
printf("no\n");
break;
}
}

a) yes
b) no
c) Compile time error
d) yes no
Answer:c

57. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 97;
switch (x)
{
case 'a':
printf("yes ");
break;
case 97:
printf("no\n");
break;
}
}
a) yes
b) yes no
c) Duplicate case value error
d) Character case value error
Answer:c

58. What is the output of this C code?

#include <stdio.h>
int main()
{
float f = 1;
switch (f)
{
case 1.0:
printf("yes\n");
break;
default:
printf("default\n");
}
}

a) yes
b) yes default
c) Undefined behaviour
d) Compile time error
Answer:d

59. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 1, z = 3;
int y = x << 3;
printf(" %d\n", y);
}

a) -2147483648
b) -1
c) Run time error
d) 8
Answer:d

60.What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 0, y = 2, z = 3;
int a = x & y | z;
printf("%d", a);
}

a) 3
b) 0
c) 2
d) Run time error
Answer:a

61. What is the output of this C code?

#include <stdio.h>
int main()
{
reverse(1);
}
void reverse(int i)
{
if (i > 5)
exit(0);
printf("%d\n", i);
return reverse(i++);
}

a) 1 2 3 4 5
b) 1 2 3 4
c) Compile time error
d) Stack overflow
Answer:d

62. What is the output of this C code?

#include <stdio.h>
void reverse(int i);
int main()
{
reverse(1);
}
void reverse(int i)
{
if (i > 5)
return ;
printf("%d ", i);
return reverse((i++, i));
}

a) 1 2 3 4 5
b) Segmentation fault
c) Compilation error
d) Undefined behaviour
Answer:a
63. In expression i = g() + f(), first function called depends on
a) Compiler
b) Associativiy of () operator
c) Precedence of () and + operator
d) Left to write of the expression
Answer:a

64. What is the value of i and j in the below code?

#include <stdio.h>
int x = 0;
int main()
{
int i = (f() + g()) || g();
int j = g() || (f() + g());
}
int f()
{
if (x == 0)
return x + 1;
else
return x - 1;
}
int g()
{
return x++;
}

a)i value is 1 and j value is 1


b)i value is 0 and j value is 0
c)i value is 1 and j value is undefined
d)i and j value are undefined
Answer:d

65. What is the value of i and j in the below code?

#include <stdio.h>
int x = 0;
int main()
{
int i = (f() + g()) | g(); //bitwise or
int j = g() | (f() + g()); //bitwise or
}
int f()
{
if (x == 0)
return x + 1;
else
return x - 1;
}
int g()
{
return x++;
}

a) i value is 1 and j value is 1


b) i value is 0 and j value is 0
c) i value is 1 and j value is undefined
d) i and j value are undefined
Answer:c

66. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = y && (y |= 10);
printf("%d\n", z);
return 0;
}

a) 1
b) 0
c) Undefined behaviour due to order of evaluation
d) 2
Answer:a

67. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = (y++) ? 2 : y == 1 && x;
printf("%d\n", z);
return 0;
}

a) 0
b) 1
c) 2
d)Undefined behaviour
Answer:b

68. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z;
z = (y++, y);
printf("%d\n", z);
return 0;
}

a) 0
b) 1
c) Undefined behaviour
d) Compilation error

Answer:b

69. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0, l;
int z;
z = y = 1, l = x && y;
printf("%d\n", l);
return 0;
}

a) 0
b) 1
c) Undefined behaviour due to order of evaluation can be different
d) Compilation error
Answer:b

70. What is the output of this C code?

#include <stdio.h>
int main()
{
int y = 2;
int z = y +(y = 10);
printf("%d\n", z);
}

a) 12
b) 20
c) 4
d) Either 12 or 20
Answer:b

71.What is the final value of j in the below code?

#include <stdio.h>
int main()
{
int i = 0, j = 0;
if (i && (j = i + 10))
//do something
;
}

a) 0
b) 10
c) Depends on the compiler
d) Depends on language standard
Answer:a

72. What is the final value of j in the below code?

#include <stdio.h>
int main()
{
int i = 10, j = 0;
if (i || (j = i + 10))
//do something
;
}

a) 0
b) 20
c) Compile time error
d) Depends on language standard
Answer:a

73. What is the output of this C code?

#include <stdio.h>
int main()
{
int i = 1;
if (i++ && (i == 1))
printf("Yes\n");
else
printf("No\n");
}

a) Yes
b) No
c) Depends on the compiler
d) Depends on the standard
Answer:b

74. function tolower(c) defined in library works for


a) Ascii character set
b) Unicode character set
c) Ascii and utf-8 but not EBSIDIC character set
d) Any character set
Answer:d

75. What is the output of the below code considering size of short int is 2, char is 1 and int is 4
bytes?

#include <stdio.h>
int main()
{
short int i = 20;
char c = 97;
printf("%d, %d, %d\n", sizeof(i), sizeof(c), sizeof(c + i));
return 0;
}

a) 2, 1, 2
b) 2, 1, 1
c) 2, 1, 4
d) 2, 2, 8
Answer:c

76. Which type conversion is NOT accepted?


a) From char to int
b) From float to char pointer
c) From negative int to char
d) From double to char
View AnswerAnswer:b

77. What will be the data type of the result of the following operation?
(float)a * (int)b / (long)c * (double)d
a) int
b) long
c) float
d) double
Answer:d

78. Which of the following type-casting have chances for wrap around?
a) From int to float
b) From int to char
c) From char to short
d) From char to int
Answer:b

79. Which of the following typecasting is accepted by C?


a) Widening conversions
b) Narrowing conversions
c) Both
d) None of the mentioned
Answer:c

80. When do you need to use type-conversions?


a) The value to be stored is beyond the max limit
b) The value to be stored is in a form not supported by that data type
c) To reduce the memory in use, relevant to the value
d) All of the mentioned
Answer: d

81.Comment on the output of this C code?

#include <stdio.h>
int main()
{
float f1 = 0.1;
if (f1 == 0.1)
printf("equal\n");
else
printf("not equal\n");
}

a) equal
b) not equal
c) Output depends on compiler
d) None of the mentionedAnswer:b

82. Comment on the output of this C code?

#include <stdio.h>
int main()
{
float f1 = 0.1;
if (f1 == 0.1f)
printf("equal\n");
else
printf("not equal\n");
}

a) equal
b) not equal
c) Output depends on compiler
d) None of the mentionedAnswer:a
83. What is the output of this C code (on a 32-bit machine)?

#include <stdio.h>
int main()
{
int x = 10000;
double y = 56;
int *p = &x;
double *q = &y;
printf("p and q are %d and %d", sizeof(p), sizeof(q));
return 0;
}

a) p and q are 4 and 4


b) p and q are 4 and 8
c) Compiler error
d) p and q are 2 and 8Answer:a

84. Which is correct with respect to size of the datatypes?


a) char > int > float
b) int > char > float
c) char < int < double
d) double > char > intAnswer:c

85. What is the output of the following C code(on a 64 bit machine)?

#include <stdio.h>
union Sti
{
int nu;
char m;
};
int main()
{
union Sti s;
printf("%d", sizeof(s));
return 0;
}

a) 8
b) 5
c) 9
d) 4Answer:d

86. What is the output of this C code?

#include <stdio.h>
int main()
{
float x = 'a';
printf("%f", x);
return 0;
}
a) a
b) run time error
c) a.0000000
d) 97.000000

Answer:d

87. Which of the datatypes have size that is variable?


a) int
b) struct
c) float
d) double

Answer:b

88.What is the output of this C code?

#include <stdio.h>
void main()
{
int a = 3;
int b = ++a + a++ + --a;
printf("Value of b is %d", b);
}

a) Value of x is 12
b) Value of x is 13
c) Value of x is 10
d) Undefined behaviour

Answer:d

89.. The precedence of arithmetic operators is (from highest to lowest)


a) %, *, /, +, -
b) %, +, /, *, -
c) +, -, %, *, /
d) %, +, -, *, /

Answer:a

90. Which of the following is not an arithmetic operation?


a) a *= 10;
b) a /= 10;
c) a != 10;
d) a %= 10;

Answer:c

91. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 2;
float f = y + x /= x / y;
printf("%d %f\n", x, f);
return 0;
}

a) 2 4.000000
b) Compile time error
c) 2 3.500000
d) Undefined behaviour

Answer:b

92. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1, y = 2;
if (x && y == 1)
printf("true\n");
else
printf("false\n");
}

a) true
b) false
c) Compile time error
d) Undefined behaviour

Answer:b

93. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 1, y = 2;
int z = x & y == 2;
printf("%d\n", z);
}

a) 0
b) 1
c) Compile time error
d) Undefined behaviour

Answer:b

94. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 3, y = 2;
int z = x /= y %= 2;
printf("%d\n", z);
}

a) 1
b) Compile time error
c) Floating point exception
d) Segmentation fault

Answer:c

95. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 3, y = 2;
int z = x << 1 > 5;
printf("%d\n", z);
}

a) 1
b) 0
c) 3
d) Compile time error

Answer:a

96. What is the output of this C code?


#include <stdio.h>
int main()
{
int x = 3; //, y = 2;
const int *p = &x;
*p++;
printf("%d\n", *p);
}

a) Increment of read-only location compile error


b) 4
c) Some garbage value
d) Undefined behaviour

Answer:c

97. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 2;
int z = x ^ y & 1;
printf("%d\n", z);
}

a) 1
b) 2
c) 0
d) 1 or 2

Answer:b

98. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = x && y = 1;
printf("%d\n", z);
}

a) 0
b) 1
c) Compile time error
d) 2
Answer:c

99. What is the output of the code given below

#include <stdio.h>
int main()
{
int x = 0, y = 2;
if (!x && y)
printf("true\n");
else
printf("false\n");
}

a) true
b) false
c) Compile time error
d) Undefined behaviour

Answer:a

100. What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 0, y = 2;
int z = ~x & y;
printf("%d\n", z);
}

a) -1
b) 2
c) 0
d) Compile time error

Answer:b
Data Structure Multiple Choice Questions & Answers Pdf

Question: 1

A data structure in which linear sequence is maintained by


pointers is known as

(A) Array

(B) Stack

(C) Linked list

(D) Pointer-based data structure

Ans: C

Linked list

Question: 2

Which of the following data structure works on the principle of


First Come First Serve?

(A) Priority queue

(B) Heap

(C) Stack

(D) Queue

Ans: D

Queue
Question: 3

A ____ is a linear collection of self-referential structures, called


nodes, connected by pointer links.

(A) Queue

(B) Linked list

(C) Tree

(D) Stack

Ans: B

Linked list

Question: 4

A queue where all elements have equal priority is a

(A) ILFO data structure

(B) LILO data structure

(C) FIFO data structure

(D) LIFO data structure

Ans: C

FIFO data structure

Question: 5

A file that is only read by a program is known as ____


(A) Input file

(B) Temporary file

(C) Work file

(D) Input/output file

Ans: A

Input file
Data Structure Objective Questions & Answers Pdf

Question: 1

Which of the following sorting algorithm is the slowest?

(A) Bubble sort

(B) Heap sort

(C) Shell sort

(D) Quick sort

Ans: A

Bubble sort

Question: 2

Which of the following data structure can be used to represent


many-to-many relation?

(A) B-tree

(B) Binary tree

(C) Graph

(D) All of above

Ans: C

Graph

Question: 3
Which of the following statement is not true about linked lists?

(A) Element in a linked list, if it is sorted, can be quickly searched


by applying binary search technique

(B) Elements are not necessarily stored in contiguous locations

(C) Insertions and deletions can be performed efficiently as


compared to arrays

(D) Linked list is a dynamic structure

Ans: A

Element in a linked list, if it is sorted, can be quickly searched by


applying binary search technique

Question: 4

Which of the following is not a linear data structure?

(A) Stack

(B) Queue

(C) Linked list

(D) Binary tree

Ans: D

Binary tree

Question: 5
Which of the following data structure permits insertion and
deletion operations only on one end of the structure?

(A) Linked list

(B) Array

(C) Stack

(D) Queue

Ans: C

Stack
Data Structure Questions & Answers Pdf

Question: 1

Which of the following data structure is more appropriate to


represent a heap?

(A) Two-dimensional array

(B) Doubly linked list

(C) Linear Array

(D) Linked list

Ans: C

Linear Array

Question: 2

Minimum number of fields in each node of a doubly linked list is


____

(A) 2

(B) 3

(C) 4

(D) None of the above

Ans: B

3
Question: 3

A graph in which all vertices have equal degree is known as ____

(A) Complete graph

(B) Regular graph

(C) Multi graph

(D) Simple graph

Ans: A

Complete graph

Question: 4

A vertex of in-degree zero in a directed graph is called a/an

(A) Root vertex

(B) Isolated vertex

(C) Sink

(D) Articulation point

Ans: C

Sink

Question: 5

A graph is a tree if and only if graph is

(A) Directed graph


(B) Contains no cycles

(C) Planar

(D) Completely connected

Ans: B

Contains no cycles
Data Structure Quiz Questions & Answers Pdf

Question: 1

A data structure in which linear sequence is maintained by


pointers is known as

Linked list

Question: 2

Which of the following data structure works on the principle of


First Come First Serve?

Queue

Question: 3

A ____ is a linear collection of self-referential structures, called


nodes, connected by pointer links.

Linked list

Question: 4

A queue where all elements have equal priority is a

FIFO data structure

Question: 5

A file that is only read by a program is known as ____

Input file

Question: 6
Which of the following sorting algorithm is the slowest?

Bubble sort

Question: 7

Which of the following data structure can be used to represent


many-to-many relation?

Graph

Question: 8

Which of the following statement is not true about linked lists?

Element in a linked list, if it is sorted, can be quickly searched by


applying binary search technique

Question: 9

Which of the following is not a linear data structure?

Binary tree

Question: 10

Which of the following data structure permits insertion and


deletion operations only on one end of the structure?

Stack
MCQs

1. Which of these best describes an array?


a) A data structure that shows a hierarchical behavior
b) Container of objects of similar types
c) Container of objects of mixed types
d) All of the mentioned
Answer: b
Explanation: Array contains elements only of the same type.

2. How do you initialize an array in C?


a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);
Answer: c
Explanation: This is the syntax to initialize an array in C.

3. How do you instantiate an array in Java?


a) int arr[] = new int(3);
b) int arr[];
c) int arr[] = new int[3];
d) int arr() = new int(3);
Answer: c
Explanation: Note that option b is declaration whereas option c is to instantiate an array.

4. Which of the following is a correct way to declare a multidimensional array in Java?


a) int[][] arr;
b) int arr[][];
c) int []arr[];
d) All of the mentioned
Answer: d
Explanation: All the options are syntactically correct.

5. What is the output of the following piece of code?

public class array


{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[2]);
System.out.println(arr[4]);
}
}

a) 3 and 5
b) 5 and 3
c) 2 and 4
d) 4 and 2
Answer: a
Explanation: Array indexing starts from 0.

6. What is the output of the following piece of code?

public class array


{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[5]);
}
}

a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InavlidInputException
Answer: c
Explanation: Trying to access an element beyond the limits of an array gives
ArrayIndexOutOfBoundsException.

7. When does the ArrayIndexOutOfBoundsException occur?


a) Compile-time
b) Run-time
c) Not an error
d) None of the mentioned
Answer: b
Explanation: ArrayIndexOutOfBoundsException is a run-time exception and the compilation is
error-free.

8. Which of the following concepts make extensive use of arrays?


a) Binary trees
b) Scheduling of processes
c) Caching
d) Spatial locality
Answer: d
Explanation: Whenever a particular memory location is referred, it is likely that the locations
nearby are also referred, arrays are stored as contigous blocks in memory, so if you want to
access array elements, spatial locality makes it to access quickly.

9. What are the advantages of arrays?


a) Easier to store elements of same data type
b) Used to implement other data structures like stack and queue
c) Convenient way to represent matrices as a 2D array
d) All of the mentioned
Answer: d
Explanation: Arrays are simple to implement when it comes to matrices of fixed size and type, or
to implement other data structures.

10. What are the disadvantages of arrays?


a) We must know before hand how many elements will be there in the array
b) There are chances of wastage of memory space if elements inserted in an array are lesser than
than the allocated size
c) Insertion and deletion becomes tedious
d) All of the mentioned
Answer: d
Explanation: Arrays are of fixed size, hence during the compile time we should know its size and
type, since arrays are stored in contigous locations, insertion and deletion becomes time
consuming.

11. Assuming int is of 4bytes, what is the size of int arr[15];?


a) 15
b) 19
c) 11
d) 60
Answer: d
Explanation: Since there are 15 int elements and each int is of 4bytes, we get 15*4 = 60bytes.

Queues:

1. A linear list of elements in which deletion can be done from one end (front) and insertion can
take place only at the other end (rear) is known as a ?
a) Queue
b) Stack
c) Tree
d) Linked list
Answer: a
Explanation: Self Explanatory.

3. A queue is a ?
a) FIFO (First In First Out) list
b) LIFO (Last In First Out) list
c) Ordered array
d) Linear tree
View Answer

Answer: a
Explanation: Self Explanatory.

4. In Breadth First Search of Graph, which of the following data structure is used?
a) Stack
b) Queue
c) Linked list
d) None of the mentioned
View Answer

Answer: b
Explanation: Self Explanatory.

5. If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in
what order will they be removed?
a) ABCD
b) DCBA
c) DCAB
d) ABCD
Answer: a
Explanation: Queue follows FIFO approach.

6. A data structure in which elements can be inserted or deleted at/from both the ends but not in
the middle is?
a) Queue
b) Circular queue
c) Dequeue
d) Priority queue
Answer: c
Explanation: Self Explanatory.

7. A normal queue, if implemented using an array of size MAX_SIZE, gets full when
a) Rear = MAX_SIZE – 1
b) Front = (rear + 1)mod MAX_SIZE
c) Front = rear + 1
d) Rear = front
Answer: a
Explanation: Condition for size of queue.

8. Queues serve major role in


a) Simulation of recursion
b) Simulation of arbitrary linked list
c) Simulation of limited resource allocation
d) All of the mentioned
Answer: c
Explanation: Rest all are implemented using other data structures.

9. Which of the following is not the type of queue?


a) Ordinary queue
b) Single ended queue
c) Circular queue
d) Priority queue
Answer: b
Explanation: Queue always has two ends.

10. In linked list implementation of queue, if only front pointer is maintained, which of the
following operation take worst case linear time?
a) Insertion
b) Deletion
c) To empty a queue
d) Both a and c
Answer: d
Explanation: Since front pointer is used for deletion, so worst time for the other two cases.

11. In linked list implementation of a queue, where does a new element be inserted?
a) At the head of link list
b) At the centre position in the link list
c) At the tail of the link list
d) None of the mentioned
Answer: c
Explanation: Since queue follows FIFO so new element inserted at last.

12. In linked list implementation of a queue, front and rear pointers are tracked. Which of these
pointers will change during an insertion into a NONEMPTY queue?
a) Only front pointer
b) Only rear pointer
c) Both front and rear pointer
d) None of the mentioned
Answer: b
Explanation: Since queue follows FIFO so new element inserted at last.
1)Which of the following type of operators have higher precedence_____
a)Relational operators b)equality operators
c)Logical operators d)Arithmatic operators
ans-Arithmatic operators

2)Which of the following operators takes only integer operands?


a)+ b)/ c)% d)*
ans-%

3)Which of the operators associate from left?


a)+ b)> c)% d)all of these
ans-all of these

4)If a,b,c are integer variables with values 1,2,3 respectively, then what is the value
of the expression
!((a+5)<(b+c))
a)0 b)6 c)5 d)1
ans-1

5) Give the value of x after execution of given code.


x=5
x=x++ +++x-x;
a)5 b)7 c)6 d)0
ans-7

6)Construct a logical expression to check whether x is largest among three


numbers x,y,z
a)x>y&&x>z b)!(x<=y||x<=z) c)x>y,z d)both a and b
ans-d

Q.7 In a circular linked list……….


(A) components are all linked together in some sequential manner.
(B) there is no beginning and no end.
(C) components are arranged hierarchically.
(D) forward and backward traversal within the list is permitted.
Ans:B
Q.8 In a linked list with n nodes, the time taken to insert an element after an
element pointed by some pointer is……..
(A) 0 (1) (B) 0 (log n) (C) 0 (n) (D) 0 (n 1og n)
Ans:A
Q.9 The data structure required to evaluate a postfix expression is …….
(A) queue (B) stack (C) array (D) linked-list
Ans:B
Q.10 Which of the following sorting methods would be most suitable for sorting a
list which is almost sorted …………
(A) Bubble Sort (B) Insertion Sort
(C) Selection Sort (D) Quick Sort
Ans:A
Q.11 Representation of data structure in memory is known as………….
(A) recursive (B) abstract data type
(C) storage structure (D) file structure
Ans:B
Q.12 The largest element of an array index is called its………..
(A) lower bound. (B) range.
(C) upper bound. (D) All of these.
Ans. (C)
Q.13 Which data structure is used for implementing recursion?
(A) Queue. (B) Stack.
(C) Arrays. (D) List.
Ans. (B)
Q.14 Null character needs a space of……………
A. zero bytes B. one byte
C. three bytes D. four bytes
Ans. (B)
Q.15 …………gives the step-by-step procedure for solving the problem which
gives correct solution.
A.Algorithm B.Array
C.Link List D.None of the above
Ans.(A)
Q.16 Which of the followings are derived data types?
A.Array B.String
C.Float D.Both ‘a’ &’b’
Ans.(D)
Q.17 Which of the followings are application of data structure?
A.Facebook B.Searching
C.Sorting D.All of the above
Ans.(D)
Q.18 Which of the following data structure is not linear data structure?
A.Array B.Linked List
C.Both of above D.None of above
Ans.(A)
Q.19 Which of the following steps are correct for solving the problem?
A.Identify the problem B.Explore information & create ideas
C.Select the best ideas D.All of these
Ans.(D)
Q20) In how many blocks Problem Analysis Chartis divided?
A) 2 B)3 C)4 D)5
Ans.(C)
Q21) Interactivity Chart is divided into subtasks called _____.
A) Function
B) Module
C) Sub program
D) None
Ans. (B)
Q 22) what is full form of IPO?
A) Input-Program-Output B) Input-Parallel-Output
C)Input-Processing-Output D) Inbuilt- Processing-Output
Ans.(C)
Q23) Algorithms are similar to____
A) Flowchart
B) Pseudo code
C) Interactivity chart
D) Problem Analysis Chart
Ans. (B)

Q24) Flowcharts can show errors in ____ which is not readily visible in the other
charts.
A) Arithmetic operations
B) Logic
C) Code
D) All of these
Ans. (B)
Q25) Which equation is to be satisfied to find the BIG-O?
A) F(n)=c*g(n)
B) F(n)>=c*g(n)
C) F(n)<=c*g(n)
D) None
ANS:C

Q26) Time Complexity is


A) Time required for the machine to compile the program.
B) Time required for the machine to execute the program.
C) Time required for the machine to debug the program.
D) None
ANS:B

Q27) Step count for the following loop is


For(int i=5; i>0; i++)
A) 5 times
B) N+1 times
C) Infinite
D) No execution
ANS:C

Q28) which of the following is not an asymptotic notation?


A) BIG-O
B) Omega
C) Phi
D) Theta
ANS:C
Q29) What is the step count of 5 th line?
1. For(int i=0, i<4, i++)
2. {
3. For(int j=5; j>0; j--)
4. {
5. Cout<<A[i][j];
6. }
7. }
A) 16
B) 25
C) 20
D) 5
ANS:C
Q.30 Which of the following character used for null….?

a) /0 b)\0 c)/n d)\n

Q.31 which of the following is not datatype…?

a)float b)long int c)long float d)long string

Q.32 Variable is…………..

a) used to store a data value

b) used to store address

c) it has fixed value

d) none of these

Q.33 In c++ float datatype allocate……..memory.

a) 4byte b) 8byte c)16byte d)1byte

Q.34 In c float datatype allocate……..memory.

a) 8byte b) 4byte c)16byte d)1byte

Q.35 For function which is sequence of syntax…?

a) define-calling-declaration

b) declaration-define-calling

c) calling-define-declaration

d) none of these
Q.36. The function written by the user according to requirement
known As…………..

a) mathematical function b) string function

c) user define function d) none of above

Q.37. Which of the following is syntax for declaration of array…?

a) datatype array_name[size]

b) datatype string name[size]

c) datatype [size] array_name

d) none of these

Q38. Which of the following is type of function…?

a) mathematical function b) statistical function

c) utility function d) all of above

Q39. Array is……….datatype

a) homogenous datatype b) heterogenous datatype

c) both a & b d) none of above

Q40. The smallest element of an array index called……

a) lower bound b) upper bound c) range d) none of above


((MARKS)) (1/2/3...) 1

((QUESTION)) What will be the output of the program ?


#include<stdio.h>

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}

((OPTION_A)) 2,1,15

((OPTION_B)) 1,2,5

((OPTION_C)) 3,2,15

((OPTION_D)) 2,3,20

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) Step 1: int a[5] = {5, 1, 15, 20, 25}; The variable arr is declared as an
(OPTIONAL) integer array with a size of 5 and it is initialized to
a[0] = 5, a[1] = 1, a[2] = 15, a[3] = 20, a[4] = 25 .
Step 2: int i, j, m; The variable i,j,m are declared as an integer type.
Step 3: i = ++a[1]; becomes i = ++1; Hence i = 2 and a[1] = 2
Step 4: j = a[1]++; becomes j = 2++; Hence j = 2 and a[1] = 3.
Step 5: m = a[i++]; becomes m = a[2]; Hence m = 15 and i is
incremented by 1(i++ means 2++ so i=3)
Step 6: printf("%d, %d, %d", i, j, m); It prints the value of the
variables i, j, m
Hence the output of the program is 3, 2, 15

((MARKS)) (1/2/3...) 1
((QUESTION)) In C, if you pass an array as an argument to a function, what actually gets
passed?
((OPTION_A)) Value of elements in array
((OPTION_B)) First element of the array

((OPTION_C)) Base address of the array

((OPTION_D)) Address of the last element of array

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) The statement 'C' is correct. When we pass an array as a funtion


(OPTIONAL) argument, the base address of the array will be passed.

((MARKS)) (1/2/3...) 1
Which of the following statements are correct about 6 used in the
((QUESTION))
program?
int num[6];
num[6]=21;
((OPTION_A)) In the first statement 6 specifies a particular element, whereas in the
second statement it specifies a type.
((OPTION_B)) In the first statement 6 specifies a array size, whereas in the second
statement it specifies a particular element of array.

((OPTION_C)) In the first statement 6 specifies a particular element, whereas in the


second statement it specifies a array size.
((OPTION_D)) In both the statement 6 specifies array size.

((CORRECT_CHOICE)) B
(A/B/C/D)
((EXPLANATION)) The statement 'B' is correct, because int num[6]; specifies the size of
(OPTIONAL) array and num[6]=21; designates the particular element(7thelement) of
the array.

((MARKS)) (1/2/3...) 1

((QUESTION)) What does the following declaration mean?


int (*ptr)[10];
((OPTION_A)) ptr is array of pointers to 10 integers

((OPTION_B)) ptr is a pointer to an array of 10 integers

((OPTION_C)) ptr is an array of 10 integers

((OPTION_D)) ptr is an pointer to array

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following statements are correct about an array?


1. The array int num[26]; can store 26 elements.
2. The expression num[1] designates the very first element in the
array.
3. It is necessary to initialize the array at the time of declaration.
4. The declaration num[SIZE] is allowed if SIZE is a macro.

((OPTION_A)) 1

((OPTION_B)) 1,4

((OPTION_C)) 2,3

((OPTION_D)) 2,4

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) 1. The array int num[26]; can store 26 elements. This statement is
(OPTIONAL) true.
2. The expression num[1] designates the very first element in the
array. This statement is false, because it designates the second
element of the array.
3. It is necessary to initialize the array at the time of declaration. This
statement is false.
4. The declaration num[SIZE] is allowed if SIZE is a macro. This
statement is true, because the MACRO just replaces the symbol SIZE
with given value.
Hence the statements '1' and '4' are correct statements.

((MARKS)) (1/2/3...) 1

((QUESTION)) The smallest element of an array index called……

((OPTION_A)) Lower bound

((OPTION_B)) Upper bound

((OPTION_C)) Range

((OPTION_D)) None of Above

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following function is used to find the first occurrence of a
given string in another string?

((OPTION_A)) strchr()

((OPTION_B)) strrchr()

((OPTION_C)) strstr()
((OPTION_D)) strnset()

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION)) char *strstr(const char *s1, const char *s2);


(OPTIONAL) Return Value:
On success, strstr returns a pointer to the element
in s1 where s2 begins (points to s2 in s1).
On error (if s2 does not occur in s1), strstr returns null.
Example:
#include <stdio.h>
#include <string.h>
int main(void)
{
char *str1 = "IndiaBIX", *str2 = "ia", *ptr;
ptr = strstr(str1, str2);
printf("The substring is: %s\n", ptr);
return 0;
}
Output: The substring is: iaBIX

((MARKS)) (1/2/3...) 1

((QUESTION)) which of the following is not an asymptotic notation?

((OPTION_A)) BIG-O

((OPTION_B)) Omega

((OPTION_C)) Phi

((OPTION_D)) Theta

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1

((QUESTION)) Step count for the following loop is


For(int i=5; i>0; i++)

((OPTION_A)) 5 times

((OPTION_B)) N+1 times

((OPTION_C)) Infinite

((OPTION_D)) No execution

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Time Complexity is

((OPTION_A)) Time required for the machine to compile the program.

((OPTION_B)) Time required for the machine to execute the program.

((OPTION_C)) Time required for the machine to debug the program.

((OPTION_D)) None

((CORRECT_CHOICE)) C
(A/B/C/D)
((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following data structure is not linear data


structure?
((OPTION_A)) Array

((OPTION_B)) Linked list

((OPTION_C)) All of above

((OPTION_D)) None of above

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the followings are application of data structure?

((OPTION_A)) Facebook

((OPTION_B)) Searching

((OPTION_C)) Sorting

((OPTION_D)) All of above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which data structure is used for implementing recursion?

((OPTION_A)) Queue

((OPTION_B)) Stack
((OPTION_C)) Array

((OPTION_D)) List

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Representation of data structure in memory is known


as………….
((OPTION_A)) recursive

((OPTION_B)) Abstract Data Type

((OPTION_C)) Storage Structure

((OPTION_D)) File Structure

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) In a linked list with n nodes, the time taken to insert an


element after an element pointed by some pointer is……..
((OPTION_A)) O (1)

((OPTION_B)) O(log n)

((OPTION_C)) O(n)

((OPTION_D)) O(n log n)


((CORRECT_CHOICE)) B
(A/B/C/D)
((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) In a circular linked list……….

((OPTION_A)) components are all linked together in some sequential


manner.

((OPTION_B)) there is no beginning and no end.

((OPTION_C)) components are arranged hierarchically.

((OPTION_D)) forward and backward traversal within the list is permitted.

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Which of the following operators takes only integer


operands?

((OPTION_A)) +

((OPTION_B)) /

((OPTION_C)) %

((OPTION_D)) *

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) NULL pointer is used to define .....

((OPTION_A)) End of the linked list

((OPTION_B)) Empty list

((OPTION_C)) Empty pointer field of the structure

((OPTION_D)) All of above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The function that return memory to heap is called...........

((OPTION_A)) Allloc()

((OPTION_B)) Malloc()

((OPTION_C)) Calloc()

((OPTION_D)) Free()

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1

((QUESTION)) Two main measures for the efficiency of an algorithm are

((OPTION_A)) Processor and memory

((OPTION_B)) Complexity and capacity

((OPTION_C)) Time and space

((OPTION_D)) Data and space

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
((QUESTION)) Which of the following case does not exist in complexity theory

((OPTION_A)) Best case

((OPTION_B)) Worst case

((OPTION_C)) Average case

((OPTION_D)) Null case

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
The Worst case occur in linear search algorithm when
((QUESTION))

((OPTION_A)) Item is somewhere in the middle of the array

((OPTION_B)) Item is not in the array at all


((OPTION_C)) Item is the last element in the array

((OPTION_D)) Item is the last element in the array or is not there at all

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) .
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The complexity of merge sort algorithm is

((OPTION_A)) O(n)

((OPTION_B)) O(log n)

((OPTION_C)) O(n2)

((OPTION_D)) O(n log n)

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The input to a merge sort is 6,5,4,3,2,1 and the same input is applied to
quick sort then which is the best algorithm in this case

((OPTION_A)) Merge sort

((OPTION_B)) Quick sort

((OPTION_C)) Both have same time complexity in this case as they have same running
time
((OPTION_D)) Cannot be decided

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
If there exists two functions f(n) and g(n). The constant c>0 and there exists
((QUESTION))
an integer constant n0>=1. If f(n)<=c*g(n) for every integer n>= n0 then we
say that____
((OPTION_A)) f(n)=O(g(n))

((OPTION_B)) f(n)=Θ (g(n))

((OPTION_C)) f(n)=𝛺 (g(n))


f(n)=Θ (g(n)) f(n)=o(g(n))

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) Basic definition of big oh notation


(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) In practice ______ is used to define tight upper bound on growth of


function f(n)

((OPTION_A)) Big oh

((OPTION_B)) Big omega

((OPTION_C)) Big theta

((OPTION_D)) None of these

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) The definition of big oh notation is f(n)<=c*g(n) which defines the


(OPTIONAL) upper bound on growth of the function f(n)
((MARKS)) (1/2/3...) 1

((QUESTION)) Examples of O(1) are ______

((OPTION_A)) Multiplying two numbers

((OPTION_B)) Assigning some value to a variable

((OPTION_C)) Displaying some integer on console

((OPTION_D)) All of the above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) All these operations are computed by single line expression


(OPTIONAL) evaluation

((MARKS)) (1/2/3...) 1

((QUESTION)) Examples of O(n2) algorithms are

((OPTION_A)) Adding two matrices

((OPTION_B)) Finding transpose of a matrix

((OPTION_C)) Initializing all elements of the matrix by 0

((OPTION_D)) All of the above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) Within two for loops(nested), all these operations are performed.
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Choose the correct time complexity of following code__

while(n>0)
{
n=n/10
}
((OPTION_A)) O(1)

((OPTION_B)) O(n)

((OPTION_C)) O(log n)

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((QUESTION)) The time complexity of binary search is_____

((OPTION_A)) O(n)

((OPTION_B)) O(log n)

((OPTION_C)) O(n log n)

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) The list is divided at the mid and then the element is searched in
(OPTIONAL) either left half or right half.

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider recurrence relation as


T(0)=c1
T(n)=T(n-1)+c2
This can be expressed as

((OPTION_A)) O(n)

((OPTION_B)) O(log n)
((OPTION_C)) O(n log n)

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) T(n)=T(n-1)+c2
(OPTIONAL) =T(n-2)+2c2
=T(n-3)+3c2
=T(n-k)+kc2
If k=n then T(n)=c1+nc2 Hence, T(n)=O(n)

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider recurrence relation as


T(0)=c1 and T(1)=c2
T(n)=T(n/2)+c3
This can be expressed as

((OPTION_A)) O(n)

((OPTION_B)) O(log n)

((OPTION_C)) O(n log n)

((OPTION_D)) O(n2)

((CORRECT_CHOICE)) B
(A/B/C/D)
((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Following is the method of solving recurrence relation

((OPTION_A)) Greedy method


((OPTION_B)) Backtracking

((OPTION_C)) Forward substitution method

((OPTION_D)) Divide and Conquer method

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1
The recurrence relation for factorial function is of the form _______
((QUESTION))

((OPTION_A)) T(n)=T(n-1)+c

((OPTION_B)) T(n)=T(n-1)+T(n-2)+c

((OPTION_C)) T(n/2)+c

((OPTION_D)) None of these

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION)) The factorial function is as follows-


(OPTIONAL) fact(n)
{
if n=1
return 1
else
return n * fact(n-1)
}

((MARKS)) (1/2/3...) 1

((QUESTION)) The recurrence relation for fibonacci function is of the form _______

((OPTION_A)) T(n)=T(n-1)+c

((OPTION_B)) T(n)=T(n-1)+T(n-2)+c
((OPTION_C)) T(n/2)+c

((OPTION_D)) None of these

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION)) The fibonacci function is as follows-


(OPTIONAL) fibb(n)
{
if n = = 0
return 0
if n = = 1
return 1
else
return (fibb(n-1) + fibb(n-2))
}

((MARKS)) (1/2/3...) 1

((QUESTION)) The frequency count of following code is____


for(i=0;i<m;i++)
{
for(j=0;i<n;j++)
{
C[i][j]=a[i][j]+b[i][j];
}
}

((OPTION_A)) m + mn + mn

((OPTION_B)) m + n + mn

((OPTION_C)) m + n2 + mn

((OPTION_D)) (m+1) + m(n+1) + mn

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)
((MARKS)) (1/2/3...) 1

((QUESTION)) Consider T(n)=15n3 + n 2 + 4. Select the correct statement

((OPTION_A)) T(n)=O(n4)

((OPTION_B)) T(n)=𝛺 (n3)

((OPTION_C)) T(n)=𝛺 (n2)

((OPTION_D)) All of the above

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Give the frequency count of 3 rd Statement

for(i=1;i<=n;i++)
for(j=1;j<=i;j++)
x=x+1;

((OPTION_A)) ½(n2+n)

((OPTION_B)) ½(n2+3n)

((OPTION_C)) n2

((OPTION_D)) (n+1)2

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) There are four algorithms for solving a problem. Their time complexities
are O(n), O(n2), O(log n) and O(n log n). Which is the best algorithm?

((OPTION_A)) O(n)

((OPTION_B)) O(n2)

((OPTION_C)) O(log n)

((OPTION_D)) O(n log n)

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The order of the recurrence relation ar-7ar-1+10ar-2=0 is ______.

((OPTION_A)) 3

((OPTION_B)) 2

((OPTION_C)) 1

((OPTION_D)) B

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Characteristic roots of the recurrence relation ar-2ar-1+ar-2=0 are _______

((OPTION_A)) 1, -1

((OPTION_B)) -1, -1

((OPTION_C)) 1, 1
((OPTION_D)) None of these

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Charactristic polynomial of the recurrence relation bn=-3bn-1-bn-2 is


________.

((OPTION_A)) Z2-3Z-2=0

((OPTION_B)) Z2+3Z-2=0

((OPTION_C)) Z2+3Z+2=0

((OPTION_D)) None of these

((CORRECT_CHOICE)) C
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) The general solution of the recurrence relation ar-2ar-1=0 is _____.

((OPTION_A)) ar=c1(-2)r

((OPTION_B)) ar=c2(2)r

((OPTION_C)) ar=c1(1)r

((OPTION_D)) None of these

((CORRECT_CHOICE)) B
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Consider the recurrence relation, an=an-1+2an-2 with a9=3 and a10=5. Find a7.

((OPTION_A)) 1

((OPTION_B)) 3

((OPTION_C)) 5

((OPTION_D)) None

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) Charactristic polynomial of the recurrence relation ar+2-ar-2=0 is ______.

((OPTION_A)) Z-1=0

((OPTION_B)) Z2-1=0

((OPTION_C)) (Z-1)2=0

((OPTION_D)) None

((CORRECT_CHOICE)) D
(A/B/C/D)

((EXPLANATION)) Given homogeneous recurrence relation can be written as


(OPTIONAL) ar+2+0ar+1+0ar+0ar-1-ar-2=0
Order of this recurrence relation is 4.
Hence characteristic polynomial is Z4-1=0
((MARKS)) (1/2/3...) 1

((QUESTION)) The postfix equivalent of the prefix *+ab-cd is ______.

((OPTION_A)) ab+cd-*

((OPTION_B)) ab+cd*-

((OPTION_C)) abcd+*-

((OPTION_D)) ab-cd+*

((CORRECT_CHOICE)) A
(A/B/C/D)

((EXPLANATION))
(OPTIONAL)

((MARKS)) (1/2/3...) 1

((QUESTION)) What does the following function check for? (all necessary headers to
be included and function is called from main)

#define MAX 10

typedef struct stack


{
int top;
int item[MAX];
}stack;

int function(stack *s)


{
if(s->top == -1)
return 1;
else return 0;
}

((OPTION_A)) full stack

((OPTION_B)) invalid index

((OPTION_C)) empty stack

((OPTION_D)) infinite stack


((CORRECT_CHOICE)) C
(A/B/C/D)
((EXPLANATION)) Answer: c
(OPTIONAL) Explanation: An empty stack is represented with the top-of-the-stack(‘top’
in this case) to be equal to -1.
MCQs

Suppose we are sorting an array of eight integers using a some quadratic sorting
algorithm. After four iterations of the algorithm’s main loop, the array elements are
ordered as shown here:2 4 5 7 8 1 3 6 *
Insertion sort
Selection sort
either of a and b
none of the above

The running time of insertion sort is *


O(n^2)
O(n)
O(log n)
O(n log n)

Which of the following sorting procedure is the slowest ? *


Quick sort
Heap sort
Shell sort
Bubble sort

A sort which compares adjacent elements in a list and switches where necessary is *
insertion sort
heap sort
quick sort
bubble sort

The correct order of the efficiency of the following sorting algorithms according to their
overall running time comparision is *
Insertion>selection>bubble
Insertion>bubble>selection
Selection>bubble>insertion
bubble>selection>insertion

A sort which iteratively passes through a list to exchange the first element with any
element less than it and then repeats with a new first element is called *
insertion sort
selection sort
heap sort
quick sort
The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 19, 5, 13 in
ascending order, using bubble sort is *
10
9
13
14

The way a card game player arranges his cards as he picks them one by one can be
compared to *
Quick sort
Merge sort
Insertion sort
Bubble sort

Which among the following is the best when the list is already sorted *
Insertion sort
Bubble sort
Merge sort
Selection sort

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 *
Bubble sort
Insertion sort
Selection sort
Merge sort
JSPM's
Jayawantrao Sawant College Of Engineering, Hadapsar,Pune-28
Department of Information Technology

Multiple Choice Questions


UNIT-II

Class: SE IT Subject: FDS

1) The value of eof is


a) -1
b) 1
c) 0
d) 10
ans:a

2) What is FILE in following declaration?


a) Keyword
b) File
c) Structure
d) Array

2) Which is file opening mode?


a) r
b) w
c) wb
d) all of the above

3) choose correct declaration


a) int main(intargc,char *argv)

{}

b) int main(intargc,char *argv[])


{}
c) int main(int *argc,char *argv)
{}
d) int main()
{int *argc,char *argv}

Ans D

4) what is output of the following program?


Void main()
{
File *fp;
Fp=fopen(“d:\\input,dat”,”w”);
Printf(“%d\n”,ferror(fp));0
}
a) 0
b) -1
c) 1
d) None of these

5) Which of the following file type can’t be opened using fopen()?


a) .txt
b) .dat
c) .bin
d) None of these

6) How to call a function without using the function name to send parameters?
a) typedefs
b) Function pointer
c) Both (a) and (b)
d) None of the mentioned
Answer:b

7) Correct syntax to pass a Function Pointer as an argument


a) void pass(int (*fptr)(int, float, char)){}
b) void pass(*fptr(int, float, char)){}
c) void pass(int (*fptr)){}
d) void pass(*fptr){}
Answer:a
8. Which of the following is not possible in C?
a) Array of function pointer
b) Returning a function pointer
c) Comparison of function pointer
d) None of the mentioned

Answer:d

9. What is the output of this C code?

#include <stdio.h>
void first()
{
printf("Hello World");
}
void main()
{
void *ptr() = first;
ptr++
ptr();
}

a) Illegal application of ++ to void data type


b) pointer function initialized like a variable
c) Both (a) and (b)
d) None of the mentioned

Answer:c

10) What will be output of the following?

void main()
{
Inta[]={1,2,3,4,5},j;
For(j=0;j<5;j++)
{
Printf(“%d”,*a);
a++;
}
}
a) Syntax error
b) Run time error
c) 12345
d) Garbage 1234

11) what will be output of following?

#include<stdio.h>
Void main()
{
Int a=10;
Int*b=&a;
Int**c=&b;
**c=20;
Printf(“%d”,a);
}
a) 10
b) 20
c) Garbage value
d) Syntax error

12) what will be o/p of following code?

Void main()
{
Intarr[]={10,20,30};
Int *p=arr;
Int *q=&p;
Printf(“%d”,(**q));
}

a) 10
b) 20
c) Sytax error
d) Runtime error

13) Output of following code?

Intmain()
{
Char *str;
Str=”%d\n”;
Str++;
Str++;
Printf(str-2,500);
Return 0;
}
a) 5
b) 50
c) 500
d) No o/p

14) how many no. Of pointer to pointer can be declared in C?

a) 7
b)127
c)255
d)no limit Ans:d

15) what is o/p of code?

Intmain()
{
Int i=10,*a;
Void *b;
a=b=&i;
printf(“%u%u”,a++,b++);
return 0;
}
a) 10 garbage value
b) Add will be display twice
c) Syntax error
d) None of these

16) Pointers are supported in

a. C
b. Fortron
c. Pascal
d. Both b&c ans:d
17)Identify invalid expression

a)&274

b)&(a+b)

c)&(a*b)

d)all of the above ans:d

18)main()

Int a=5;

Ptr=&a;

Printf(“%d”,++*ptr);

Output will be:

a)6

b)5

c)0

d)none

ans:a

19)Number of argument use in malloc is

a) 0
b) 1
c) 2
d) 3
ans:1
20) The no. Of argument use in realloc is
a) 0
b) 1
c) 2
d) 3
ans:c
21) the function is use in dynamic deallocation is
a) Destroy()
b) Delet()
c) Free
d) Remove()
ans:c

22) the function call realloc(ptr,0)is


a) Same as free (ptr)

b) Used to set the value of ptr to be 0

c) the value of in the address represented by ptr

d) Invalid

ans:a

23) pointers can be used to achive


a) Call by function
b) Call by refrance
c) Call by name
d) Call y procedure
ans:b

24) the declaration of float *a[5] is

a) An ordinary array
b) A pointer to an array
c) Ann array to an pointer
d) Pointer to an array
ans:c

25) The declaration int (*p)[8];


a) An array of pointer
b) A pointer to an array
c) Pointer to function
d) Function returing pointer
ans:b

26) Given int a[5][5];identify the correct expression ,yielding the starting element.
a) *a[0]
b) **a
c) a[0][0]
d) all of these
ans:d

27) Given int x[5][5][5];find value of the element x[2][3][4]


a) *(x[2][3]+4)
b) *(*(x[2]+3)+4)
c) *(*(*(x+2)+3)+4)
d) All of the above

28)The oprators used in pointr is


a) *and/
b) &and*
c) &and|
d) –and>

ans:b

29) main()
{
Inta[5]={-2,-1,3,4,5}
Int*b;
b=&a[2];
}
Then value of b[-1] is:
a) 4
b) 3
c) -1
d) -2
ans:c
30)identify invalid pointer oprator
a) &
b)>>
c) *
d)None of these
ans:b

31)Identify the wrong declaration statement.

a)int *p,a=10;

b)int a=10,*p=&a;

c)int *p=&a,a=10

d)options a and b

32) Identify the invalid expression given

intnum=15,*p=&num;

a)*num

b)*(&num)

c)*&*&num

d)**&p

33) Identify the invalid expression given float x=2.14,*y=&x;

a)&y

b)*&x

c)**&y

d)(*&)x

34)The operand of the address of operator is

a)a constant

b)an expression

c)a named region of storage

d)a register variable


35)How does compiler differentiate address of operator from bitwise AND operator?

a)by using the number of operands and the position of operands

b)by seeing the declarations

c)both options a and b

d)by using the value of the operand

36)How does compiler differentiate indirection operator from multiplication operator?

a) by using the number of operands

b) by seeing the position of operands

c) both options a and b

d)by using the value of the operand

37)The address of operator returns

a)the address of its operand

b)lvalue

c) both options a and b

d)rvalue

38)The indirection operator returns

a)the data object stored in the address represented by its operand

b)lvalue

c)both options a and b

d)rvalue
39)The operand of indirection operator is

a)pointer variable

b)pointer expression

c)both options a and b

d)ordinary variable

40)The operand of address of operator may be

a)an ordinary variable

b)an array variable

c)a pointer variable

d)Any one of above

41)Identify the invalid lvalue given int x,*p=&x;

a)*(p+1)

b)*(p-3)

c)both options a and b

d)&x

42)After the execution of statement int x; the value of x is

a)0

b)undefined

c)1

d)-1

43)Pointer variable may be initialized using


a)static memory allocation

b)dynamic memory allocation

c)both options a and b

d)a positive integer

44)Given the declaration double prec[5]; the address of element prec[2]is obtained

a)&prec[2]

b)prec+2

c)both options a and b

d)*(prec+2)

45)Identify the correct statement for given expression

floatfnum[10];

a)fnum is pointer variable

b)fnum is fixed address and not a variable.

c)fnum is an array variable

d)fnum is an address that can be modified.

46)Which is the correct function header for function main()?

a)main(intargc, char *argv[])

b)main(intargc, char **argv)

c)main(intargc, char *av[])

d)all the above

47)The invalid address arithmetic is


a)adding two pointers

b)multiplying two pointers

c)dividing two pointers

d)all the above

48)Identify the invalid assignment,for given int *p,x;

a)p=0;

b)p=255864u

c)p=&x

d)*p=10

49)Identify the invalid expression for given syntax:

float fnum[10],*fptr=fnum;

a)fnum+4

b)fnum[4]

c)fnum=++fptr

d)&fnum[4]

50)The operators &,*,++ and – have

a)same procedure level and same associativity

b)same associativity and different precedence level

c)different precedence level and different associativity

d)different precedence level and same associativity


51.What is the output of this C code?

#include <stdio.h>
int mul(int a, int b, int c)
{
return a * b * c;
}
void main()
{
int (*function_pointer)(int, int, int);
function_pointer = mul;
printf("The product of three numbers is:%d",
function_pointer(2, 3, 4));
}

a) The product of three numbers is:24


b) Run time error
c) Nothing
d) Varies

Answer:a

52. What is the output of this C code?

#include <stdio.h>
int mul(int a, int b, int c)
{
return a * b * c;
}
void main()
{
int (function_pointer)(int, int, int);
function_pointer = mul;
printf("The product of three numbers is:%d",
function_pointer(2, 3, 4));
}

a) The product of three numbers is:24


b) Compile time error
c) Nothing
d) Varies

Answer:b
53. What is the output of this C code?

#include <stdio.h>
void f(int (*x)(int));
int myfoo(int);
int (*fooptr)(int);
int ((*foo(int)))(int);
int main()
{
fooptr = foo(0);
fooptr(10);
}
int ((*foo(int i)))(int)
{
return myfoo;
}
int myfoo(int i)
{
printf("%d\n", i + 1);
}

a) 10
b) 11
c) Compile time error
d) Undefined behaviour

Answer:b

54. Which is an indirection operator among the following?


a) &
b) *
c) ->
d) .

Answer:b

55. Which of the following does not initialize ptr to null (assuming variable declaration of a as
int a=0;?
a) int *ptr = &a;
b) int *ptr = &a – &a;
c) int *ptr = a – a;
d) All of the mentioned

Answer:a

56. What is the output of this C code?

#include <stdio.h>
int x = 0;
void main()
{
int *ptr = &x;
printf("%p\n", ptr);
x++;
printf("%p\n ", ptr);
}

a) Same address
b) Different address
c) Compile time error
d) Varies

Answer:a

57. What is the output of this C code?

#include <stdio.h>
int x = 0;
void main()
{
int *const ptr = &x;
printf("%p\n", ptr);
ptr++;
printf("%p\n ", ptr);
}

a) 0 1
b) Compile time error
c) 0xbfd605e8 0xbfd605ec
d) 0xbfd605e8 0xbfd605e8

Answer:b
58. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 0;
int *ptr = &x;
printf("%p\n", ptr);
ptr++;
printf("%p\n ", ptr);
}

a) 0xbfd605e8 0xbfd605ec
b) 0xbfd605e8 0cbfd60520
c) 0xbfd605e8 0xbfd605e9
d) Run time error

Answer:a

59. What is the output of this C code?

#include <stdio.h>
void main()
{
int x = 0;
int *ptr = &5;
printf("%p\n", ptr);
}

a) 5
b) Address of 5
c) Nothing
d) Compile time error

Answer:d

60. What is the output of this C code?

#include <stdio.h>
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
**m = 6;
printf("%d\n", k);
}

a) 5
b) Compile time error
c) 6
d) Junk

Answer:c

61. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int *r = &p;
printf("%d", (**r));
}

a) 1
b) Compile time error
c) Address of a
d) Junk value

Answer:b

62. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int **r = &p;
printf("%p %p", *r, a);
}

a) Different address is printed


b) 1 2
c) Same address is printed.
d) 1 1

Answer:c

63. How many number of pointer (*) does C have against a pointer variable declaration?
a) 7
b) 127
c) 255
d) No limits.

Answer:d

64. What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;
int **sptr = &ptr1; //-Ref
*sptr = ptr2;
}

a) ptr1 points to a
b) ptr1 points to b
c) sptr points to ptr2
d) None of the mentioned

Answer:b

65. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int **r = &p;
printf("%p %p", *r, a);
}
a) Different address is printed
b) 1 2
c) Same address is printed.
d) 1 1

Answer:c

66. What substitution should be made to //-Ref such that ptr1 points to variable C?

#include <stdio.h>
int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a;
int **sptr = &ptr1;
//-Ref
}

a) *sptr = &c;
b) **sptr = &c;
c) *ptr1 = &c;
d) None of the mentioned.

Answer:a

67. Which of the following declaration throw run-time error?


a) int **c = &c;
b) int **c = &*c;
c) int **c = **c;
d) None of the mentioned

Answer:d

68. Comment on the output of this C code?

#include <stdio.h>
int main()
{
int a = 10;
int **c -= &&a;
}

a) You cannot apply any arithmetic operand to a pointer.


b) We don’t have address of an address operator
c) Both (a) and (b)
d) None of the mentioned.

Answer:b

69. What is the output of this C code?

#include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int *r = &p;
printf("%d", (**r));
}

a) 1
b) Compile time error
c) Address of a
d) Junk value

Answer:b

70. Comment on the output of this C code?

#include <stdio.h>
int main()
{
char *str = "This" //Line 1
char *ptr = "Program\n"; //Line 2
str = ptr; //Line 3
printf("%s, %s\n", str, ptr); //Line 4
}

a) Memory holding “this” is cleared at line 3


b) Memory holding “this” loses its reference at line 3
c) You cannot assign pointer like in Line 3
d) Output will be This, Program

Answer:b

71. What type initialization is needed for the segment “ptr[3] = ’3′;” to work?
a) char *ptr = “Hello!”;
b) char ptr[] = “Hello!”;
c) Both (a) and (b)
d) None of the mentioned

Answer:b

73. The syntax for constant pointer to address (i.e., fixed pointer address) is:

a) const <type> * <name>


b) <type> * const <name>
c) <type> const * <name>
d) Both (a) and (c)
Answer:b

74. Comment on the output of this C code?

#include <stdio.h>
int add(int a, int b)
{
return a + b;
}
int main()
{
int (*fn_ptr)(int, int);
fn_ptr = add;
printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3));
}

a) Compile time error, declaration of a function inside main.


b) Compile time error, no definition of function fn_ptr.
c) Compile time error, illegal application of statement fn_ptr = add.
d) No Run time error, output is 5.

Answer:d
75. The correct way to declare and assign a function pointer is done by:
(Assuming the function to be assigned is “int multi(int, int);”)
a) int (*fn_ptr)(int, int) = multi;
b) int *fn_ptr(int, int) = multi;
c) int *fn_ptr(int, int) = &multi;
d) Both (b) & (c)

Answer:a

76. Calling a function f with a an array variable a[3] where a is an array, is equivalent to
a) f(a[3])
b) f(*(a + 3))
c) f(3[a])
d) All of the mentioned

Answer:d

77. What is the output of this C code?

#include <stdio.h>
void f(char *k)
{
k++;
k[2] = 'm';
}
void main()
{
char s[] = "hello";
f(s);
printf("%c\n", *s);
}

a) h
b) e
c) m
d) o;

Answer:a

78.What is the output of this C code?


#include <stdio.h>
void main()
{
char s[] = "hello";
s++;
printf("%c\n", *s);
}

a) Compile time error


b) h
c) e
d) o

Answer:a

81. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m;
s->c = "hello";
printf("%s", s->c);
}

a) hello
b) Run time error
c) Nothing
d) Depends on compiler

Answer:a

82. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student *s;
s->c = "hello";
printf("%s", s->c);
}

a) hello
b) Segmentation fault
c) Run time error
d) Nothing

Answer:b

83. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m;
s->c = "hello";
printf("%s", m.c);
}

a) Run time error


b) Nothing
c) hello
d) Varies

Answer:c

84. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m;
(*s).c = "hello";
printf("%s", m.c);
}

a) Run time error


b) Nothing
c) Varies
d) hello

Answer:d

85. What is the output of this C code?

#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student n;
struct student *s = &n;
(*s).c = "hello";
printf("%p\n%p\n", s, &n);
}

a) Different address
b) Run time error
c) Nothing
d) Same address

Answer:d

86. What is the output of this C code?

#include <stdio.h>
struct p
{
int x[2];
};
struct q
{
int *x;
};
int main()
{
struct p p1 = {1, 2};
struct q *ptr1;
ptr1->x = (struct q*)&p1.x;
printf("%d\n", ptr1->x[1]);
}

a) Compile time error


b) Segmentation fault/code crash
c) 2
d) 1

Answer:b

87. What is the output of this C code?

#include <stdio.h>
struct p
{
int x[2];
};
struct q
{
int *x;
};
int main()
{
struct p p1 = {1, 2};
struct q *ptr1 = (struct q*)&p1;
ptr1->x = (struct q*)&p1.x;
printf("%d\n", ptr1->x[0]);
}

a) Compile time error


b) Undefined behaviour
c) Segmentation fault/code crash
d) 1

Answer:b
88. What is the output of this C code?

#include <stdio.h>
struct p
{
int x;
int y;
};
int main()
{
struct p p1[] = {1, 2, 3, 4, 5, 6};
struct p *ptr1 = p1;
printf("%d %d\n", ptr1->x, (ptr1 + 2)->x);
}

a) 1 5
b) 1 3
c) Compile time error
d) 1 4

Answer:a

89. What is the output of this C code?

#include <stdio.h>
struct p
{
int x;
char y;
};
int main(){
struct p p1[] = {1, 92, 3, 94, 5, 96};
struct p *ptr1 = p1;
int x = (sizeof(p1) / sizeof(struct p));
printf("%d %d\n", ptr1->x, (ptr1 + x - 1)->x);
}

a) Compile time error


b) Undefined behaviour
c) 1 3
d) 1 5

Answer:d
91. What is the output of this C code (considering sizeof char is 1 and pointer is 4)?

#include <stdio.h>
int main()
{
char *a[2] = {"hello", "hi"};
printf("%d", sizeof(a));
return 0;
}

a) 9
b) 4
c) 8
d) 10

Answer:c

92. What is the output of this C code?

#include <stdio.h>
int main()
{
char a[2][6] = {"hello", "hi"};
printf("%d", sizeof(a));
return 0;
}

a) 9
b) 12
c) 8
d) 10

Answer:b

93. What is the output of this C code?

#include <stdio.h>
int main()
{
char a[2][6] = {"hello", "hi"};
printf("%s", *a + 1);
return 0;
}
a) hello
b) hi
c) ello
d) ello hi

Answer:c

94. What is the output of this C code?

#include <stdio.h>
int main()
{
char *a[2] = {"hello", "hi"};
printf("%s", *(a + 1));
return 0;
}

a) hello
b) ello
c) hi
d) ello hi

Answer:c

95. Advantage of a multi-dimension array over pointer array.


a) Pre-defined size.
b) Input can be taken from user.
c) Faster Access.
d) All of the mentioned

Answer:d

96. Which of the following operation is possible using a pointer char?


(Assuming declaration char *a;)
a) Input via %s
b) Generation of multidimensional array
c) Changing address to point at another location
d) All of the mentioned
Answer:c

97. Comment on the following two operations?


int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1
int b[4][4] = {{1, 2, 3}, {1, 2, 3, 4}};//- 2
a) 1 will work, 2 will not
b) 1 and 2, both will work
c) 1 won’t work, 2 will work
d) Neither of them will work

Answer:c

98. Comment on the following two operations?


int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1
int b[][] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 2
a) 1 works, 2 doesn’t
b) 2 works, 1 doesn’t
c) Both of them work
d) Neither of them work

Answer:d

99. What does argv and argc indicate in command-line arguments?


(Assuming: int main(int argc, char *argv[]) )
a) argument count, argument variable
b) argument count, argument vector
c) argument control, argument variable
d) argument control, argument vector

Answer:b

100. Which of the following syntax is correct for command-line arguments?


a) int main(int var, char *varg[])
b) int main(char *argv[], int argc)
c) int main()
{
int argv, char *argc[];
}
d) Both (a) and (b)

Answer:a

101. In linux, argv[0] by command-line argument can be occupied by


a) ./a.out
b) ./test
c) ./fun.out.out
d) All of the mentioned

Answer:d

102. What type of array is generally generated in Command-line argument?


a) Single dimension array
b) 2-Dimensional Square Array
c) Jagged Array
d) 2-Dimensional Rectangular Array

Answer:c

103. What would be the output if we try to execute following segment of code (assuming the
following input “cool brother in city”)?
printf(“%s\n”, argv[argc]);
a) (null)
b) City
c) In
D. Segmentation Fault

Answer:a

104. The first argument in command line arguments is


a) The number of command-line arguments the program was invoked with;
b) A pointer to an array of character strings that contain the arguments
c) Nothing
d) Both a & b
105. The second (argument vector) in command line arguments is
a) The number of command-line arguments the program was invoked with;
b) A pointer to an array of character strings that contain the arguments,one per string.
c) Nothing
d) Both a & b

Answer:b

106. argv[0] in command line arguments, is


a) The name by which the program was invoked
b) The name of the files which are passed to the program
c) Count of the arguments in argv[] vector
d) Both a & b

Answer:a
JSPM's
Jayawantrao sawant College of EngineeringHadpsar, Pune-33
Department of Information Technology
Multiple Choice Questions

Unit-3

1. Two main measures for the efficiency of an algorithm are


a. Processor and memory
b. Complexity and capacity
c. Time and space
d. Data and space

2. The time factor when determining the efficiency of algorithm is measured by


a. Counting microseconds
b. Counting the number of key operations
c. Counting the number of statements
d. Counting the kilobytes of algorithm

3. The space factor when determining the efficiency of algorithm is measured by


a. Counting the maximum memory needed by the algorithm
b. Counting the minimum memory needed by the algorithm
c. Counting the average memory needed by the algorithm
d. Counting the maximum disk space needed by the algorithm

4. Which of the following case does not exist in complexity theory


a. Best case
b. Worst case
c. Average case
d. Null case

5. The Worst case occur in linear search algorithm when


a. Item is somewhere in the middle of the array
b. Item is not in the array at all
c. Item is the last element in the array
d. Item is the last element in the array or is not there at all
6. The Average case occur in linear search algorithm
a. When Item is somewhere in the middle of the array
b. When Item is not in the array at all
c. When Item is the last element in the array
d. When Item is the last element in the array or is not there at all

7. The complexity of the average case of an algorithm is


a. Much more complicated to analyze than that of worst case
b. Much more simpler to analyze than that of worst case
c. Sometimes more complicated and some other times simpler than that of worst case
d. None or above

8. The complexity of linear search algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

9. The complexity of Binary search algorithm is


a. O(n)
b. O(log )
c. O(n2)
d. O(n log n)

11. The complexity of merge sort algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

12. The indirect change of the values of a variable in one module by another module is called
a. internal change
b. inter-module change
c. side effect
d. side-module update
13. Which of the following data structure is not linear data structure?
a. Arrays
b. Linked lists
c. Both of above
d. None of above

14. Which of the following data structure is linear data structure?


a. Trees
b. Graphs
c. Arrays
d. None of above

15. The operation of processing each element in the list is known as


a. Sorting
b. Merging
c. Inserting
d. Traversal

16. Finding the location of the element with a given value is:
a. Traversal
b. Search
c. Sort
d. None of above

17. Arrays are best data structures


a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

18. Linked lists are best suited


a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

19. Each array declaration need not give, implicitly or explicitly, the information about
a. the name of array
b. the data type of array
c. the first data from the set to be stored
d. the index set of the array

20. The elements of an array are stored successively in memory cells because
a. by this way computer can keep track only the address of the first element and the
addresses of other elements can be calculated
b. the architecture of computer memory does not allow arrays to store other than serially
c. both of above
d. none of above

21. When determining the efficiency of algorithm, the space factor is measured by
a. Counting the maximum memory needed by the algorithm
b. Counting the minimum memory needed by the algorithm
c. Counting the average memory needed by the algorithm
d. Counting the maximum disk space needed by the algorithm

22. The complexity of Bubble sort algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

23. Linked lists are best suited


a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

24. If the values of a variable in one module is indirectly changed by another module, this
situation is called
a. internal change
b. inter-module change
c. side effect
d. side-module update
25. In linear search algorithm the Worst case occurs when
a. The item is somewhere in the middle of the array
b. The item is not in the array at all
c. The item is the last element in the array
d. The item is the last element in the array or is not there at all

26. For an algorithm the complexity of the average case is


a. Much more complicated to analyze than that of worst case
b. Much more simpler to analyze than that of worst case
c. Sometimes more complicated and some other times simpler than that of worst case
d. None or above

27. The complexity of merge sort algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

28. The complexity of linear search algorithm is


a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

29. When determining the efficiency of algorithm the time factor is measured by
a. Counting microseconds
b. Counting the number of key operations
c. Counting the number of statements
d. Counting the kilobytes of algorithm

30. Which of the following data structure is linear data structure?


a. Trees
b. Graphs
c. Arrays
d. None of above

31. The elements of an array are stored successively in memory cells because
a. by this way computer can keep track only the address of the first element and the
addresses of other elements can be calculated
b. the architecture of computer memory does not allow arrays to store other than serially
c. both of above
d. none of above

32. Which of the following data structure is not linear data structure?
a. Arrays
b. Linked lists
c. Both of above
d. None of above

33. The Average case occur in linear search algorithm


a. When Item is somewhere in the middle of the array
b. When Item is not in the array at all
c. When Item is the last element in the array
d. When Item is the last element in the array or is not there at all

34. Two main measures for the efficiency of an algorithm are


a. Processor and memory
b. Complexity and capacity
c. Time and space
d. Data and space

35. Finding the location of the element with a given value is:
a. Traversal
b. Search
c. Sort
d. None of above

36. Which of the following case does not exist in complexity theory
a. Best case
b. Worst case
c. Average case
d. Null case

37. The operation of processing each element in the list is known as


a. Sorting
b. Merging
c. Inserting
d. Traversal

38. Arrays are best data structures


a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

39. Each array declaration need not give, implicitly or explicitly, the information about
a. the name of array
b. the data type of array
c. the first data from the set to be stored
d. the index set of the array
40. The complexity of Binary search algorithm is
a. O(n)
b. O(log )
c. O(n2)
d. O(n log n)

41.Which of the following data structure is non-linear type?


A) Strings
B) Lists
C) Stacks
D) Tree

42. Which of the following data structure is linear type?


A) Array
B) Tree
C) Graphs
D) Hierarchy

43. The logical or mathematical model of a particular organization of data is called a .........
A) Data structure
B) Data arrangement
C) Data configuration
D) Data formation

44. The simplest type of data structure is ..................


A) Multidimensional array
B) Linear array
C) Two dimensional array
D) Three dimensional array

45. Linear arrays are also called ...................


A) Straight line array
B) One-dimensional array
C) Vertical array
D) Horizontal array

46. Arrays are best data structures ............


A) For relatively permanent collections of data.
B) For the size of the structure and the data in the structure are constantly changing
C) For both of above situation
D) For none of the above

47. Which of the following data structures are indexed structures?


A) Linear arrays
B) Linked lists
C) Graphs
D) Trees

48. Each node in a linked list has two pairs of .............. and ...................
A) Link field and information field
B) Link field and avail field
C) Avail field and information field
D) Address field and link field

49. A ........................ does not keep track of address of every element in the list.
A) Stack
B) String
C) Linear array
D) Queue

50. When does top value of the stack changes?


A) Before deletion
B) While checking underflow
C) At the time of deletion
D) After deletion
JSPM's
Jayawantrao sawant College of EngineeringHadpsar, Pune-33
Department of Information Technology
Multiple Choice Questions

Unit-4

1.Which of the following best describes sorting ?


A.Accessing and processing each record exactly once
B.Finding the location of the record with a given key
C.Arranging the data (record) in some given order
D.Adding a new record to the data structure
ANSWER: C

2.The time complexity of linear search algorithm over an array of n elements is


A.O (log2 n)
B.O(n)
C.O(n log2 n)
D.0 (n2)
ANSWER: B

3.A characteristic of the data that binary search uses but the linear search ignores is
the___________
A.Order of the elements of the list
B.Length of the list
C.Maximum value in list
D.Type of elements of the list
ANSWER: A

4.The data for which you are searching is called


A.search argument
B.sorting argument
C.detection argument
D.binary argument
ANSWER: A

5.For a linear search in an array of n elements the time complexity for best, worst and average
case are ......., ....... and ........ respectively
A.O(n), O(1), and O(n/2)
B.O(1), O(n) and O(n/2)
C.O(1),O(n) and O(n)
D.O(1), O(n) and (n-1/2)
ANSWER: C
6.Which of the following is false ?
A.A serial search begins with the first array element
B.A serial search continues searching, element by element, either until a match is found or until
the end of the array is encountered
C.A serial search is useful when the amount of data that must be search is small
D.For a serial search to work, the data in the array must be arranged in either alphabetical or
numerical order
ANSWER: D

7.The average successful search time for sequential search on 'n' items is
A.n/2
B.(n-1)/2
C.(n+1)/2
D.log (n)+1
ANSWER: C

8.A search begins the search with the element that is located in the middle of the array
A.serial
B.random
C.parallel
D.binary
ANSWER: D

9.Suppose DATA array contains 1000000 elements. Using the binary search algorithm, one
requires only about n comparisons to find the location of an item in the DATA array, then n is
A.60
B.45
C.20
D.None of these
ANSWER: C

10.Which of the following is false ?


A.A binary search begins with the middle element in the array
B.A binary search continues having the array either until a match is found or until there are no
more elements to search
C.If the search argument is greater than the value located in the middle of the binary, the binary
search continues in the upper half of the array
D.For a binary search to work, the data in the array must be arranged in either alphabetical or
numerical order
ANSWER: C

11.The order of the binary search algorithm is


A.n
B.n2
C.nlog(n)
D.log(n)
ANSWER: Option D

12.Sorting is useful for


A.report generation
B.respondingtoe queries easily
C.making searching easier and efficient
D.All of these
ANSWER: D

13.Choose the correct statements


A.Internal sorting is used if the number of items to be sorted is very large.
B.External sorting is used if the number of items to be sorted is very large
C.External sorting needs auxilary storage
D.Both (b) & (c)
ANSWER: D

14.A sort which compares adjacent elements in a list and switches where necessary is
A.insertion sort
B.heap sort
C.quick sort
D.bubble sort
ANSWER: D

15.Which of the following sorting methods would be most suitable for sorting a list which is
almost sorted
A.Bubble Sort
B.Insertion Sort
C.Selection Sort
C.Quick Sort
ANSWER: A

16.Which of the following sorting procedure is the slowest ?


A.Quick sort
B.Heap sort
C.Shell sort
D.Bubble sort
ANSWER: D

17.The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 19, 5, 13 in ascending
order, using bubble sort is
A.11
B.12
C.13
D.14
ANSWER: D

18.A machine took 200 sec to sort 200 names, using bubble sort. In 800 sec, it can approximately
sort
A.400 names
B.800 names
C.750 names
D.800 names
ANSWER: A

19.Given a file of size n the number of times a given file is passed through in bubble sort is
A.n2
B.n - 1
C.n log n
ANSWER: B

20.In bubble sort, for a file of size n, after p iterations number of records in proper positions is
A.n - p
B.n - p + 1
C.p
ANSWER: A

21.A sort which iteratively passes through a list to exchange the first element with any element
less than it and then repeats with a new first element is called
A.insertion sort
B.selection sort
C.heap sort
D.quick sort
ANSWER: B

22.Which of the following sorting methods will be the best if number of swappings done, is the
only measure of efficienty?
A.Bubble sort
B.Selection sort
C.Insertion sort
D.Quick sort
ANSWER: B
23.What is the number of swaps required to sort n elements using selection sort, in the worst
case?
A.T(n)
B.T(n log n)
C.T(n2)
D.T(n2 log n)
ANSWER: A

24.Staright selection sort is basically a method of repeated


A.interchange
B.searching
C.position adjustment
ANSWER: C

25.Number of selections required to sort a file of size N by straight selection requires


a.N - 1
b.log N
c.O(N2)
ANSWER: A

26.For sorting a file of size n by straight selection sort, the number of comparisons made in the
first pass is
a.n
b.n - 1
c.n(n - 1)/2
ANSWER: B

27.Which of the following sorting method is stable ?


A.insertion sort
B.Quick sort
C.Shell sort
D.Heap sort
ANSWER: A

28.You have to sort a list L consisting of a sorted list followed by a few “random”
elements.Which of the following sorting methods would be especially suitable for such a task?
A.Bubble sort
B.Selection sort
C.Quick sort
D.Insertion sort
Ans:D
29.Which of the following sorting methods would be most suitable for sorting a list which is
already sorted
A.Bubble Sort
B.Insertion Sort
C.Selection Sort
C.Quick Sort
ANSWER: B

30.The way a card game player arranges his cards as he picks them up one by one, is an example
of
A.bubble sort
B.Selection sort
C.insertion sort
D.merge sort
ANSWER: C

31.You want to check whether a given set of items is sorted. Which of the following sorting
methods will be most efficient if it is already in sorted order?
A.Bubble sort
B.Selection sort
C.Insertion sort
D.Merge Sort
ANSWER: C

32.Which of the following sorting algorithms does not have a worst case running time of O(n2)?
A.Insertion sort
B.Merge sort
C.Quick sort
D.Bubble sort
ANSWER: B

33.Merge sort uses


A.divide and conquer strategy
B.backtracking approach
C.heuristic search
D.greedy approach
ANSWER: A

34.Assume 5 buffer pages are available to sort a file of 105 pages. The cost of sorting using m-
way merge sort is
A.206
B.618
C.840
D.926
ANSWER: C

35.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
Answer: A

36.Quick sort is also known as


A.Merge sort
B.Heap sort
C.Bubble sort
C.None of these
ANSWER: D

37.A sort which relatively passes through a list to exchange the first element with any element
less than it and then repeats with a new first element is called
A.Insertion sort
B.Selection sort
C.Heap sort
D.Quick sort
ANSWER: D

39.The best average behaviour is shown by


38.A.Quick Sort
B.Merge Sort
C.Insertion Sort
C.Heap Sort
ANSWER: A

40.Which of the following sorting methods sorts a given set of items that is already in sorted
order or in reverse sorted order with equal speed?
A.Heap sort
B.Quick sort
C.Insertion sort
D.Selection sort
ANSWER: B

41.A machine needs a minimum of 100 sec to sort 1000 names by quick sort. The minimum time
needed to sort 100 names will be approximately
A.50.2 sec
B.6.7 sec
C.72.7 sec
D.11.2 sec
ANSWER: B

42.Which of the following is useful in implementing quick sort?


A.Stack
B.Set
C.List
D.Queue
ANSWER: A

43.In quick sort, for sorting n elements, the (n/4)th smallest element is selected as pivot using an
T(n) time algorithm. What is the worst case time complexity of the quick sort?
A.T(n)
B.T(n log n)
C.T(n2)
D.T(n2 log n)
ANSWER: B

44.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
ANSWER: C

45.In worst case Quick Sort has order


A.O (n log n)
B.O (n^2/2)
C.O (log n)
D.O (n2/4)
ANSWER: B

46.In quick sort, the number of partitions into which the file of size n is divided by a selected
record is
A.n
B.n - 1
C.2
ANSWER: C

47.The total number of comparisons made in quick sort for sorting a file of size n, is
a.O(n log n)
b.O(n2)
c.n(log n)
ANSWER: A

48.Quick sort efficiency can be improved by adopting


a.non-recursive method
b.insertion method
c.tree search method
ANSWER: A

49.For the improvement of efficiency of quick sort the pivot can be


a.the first element
b.the mean element
c.the last element
ANSWER: B

50.Quick sort is the fastest available method of sorting because of


a.low over head
b.O(n log n) comparisons
c.lowover head and also O(n log n) comparisons
ANSWER: C

51.A sorting technique that guarantees that records with the same primary key occurs in the same
order in the sorted list as in the original unsorted list is said to be
A.stable
B.consistent
C.External
D.linear
ANSWER: A
UNIT-1
Marks distribution for Unit 1

4 + 4+ 2 +2 +1 = 13 Marks (Only 2 Question will be asked for 4 marks , 2 Questions will be asked for 2 Marks,
1 Question will be asked for 1 Mark )
Syllabus for Unit-1

Algorithms- Problem Solving, Introduction to Algorithms, Characteristics of algorithms, Algorithm design


tools: Pseudo code and flowchart, Analysis of Algorithms, Complexity of algorithms- Space complexity, Time
complexity, Asymptotic notation- Big-O, Theta and Omega, standard measures of efficiency.
Data Structures- Data structure, Abstract Data Types (ADT), Concept of linear and Non-linear, static and
dynamic, persistent and ephemeral data structures, and relationship among data, data structure, and algorithm,
From Problem to Program.
Algorithmic Strategies- Introduction to algorithm design strategies- Divide and Conquer, and Greedy strategy.
Recurrence relation - Recurrence Relation, Linear Recurrence Relations, With constant Coefficients,
Homogeneous Solutions. Solving recurrence relations
Reference Book:

• “Fundamentals of Algorithmics”, Brassard & Bratley, ISBN 13-9788120311312


Id 1
Question The most common data types are..............
A Numeric, character, and logical.
B Array, integer and float
C Variable, Character and logical
D main, float and print
Answer A
Marks 2

Id 2
Question Numeric data include...........
A Double and Float
B integers and real numbers

C long int and short int


D None of these
Answer B
Marks 2

Id 3
Question Range for Positive & Negative Integers numbers are.......
A 4,792 or -637
B 5,297 or -376
C 9724 or -367
D 3,297 or -376
Answer B
Marks 2

Page 1
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 4
Question structure chart Or interactivity chart Shows -----------------
A input, the processing, and the output;
B a beginning analysis of the problem
C overall layout or structure of the solution;
D a language like solution
Answer C
Marks 2
Unit 1

Id 5
Question IPO chart, shows -----------------
A a language like solution
B a beginning analysis of the problem
C overall layout or structure of the solution;
D input, the processing, and the output;
Answer Correct Option D
Marks 2
Unit 1

Id 6
Question pseudo code shows --------------
A input, the processing, and the output;
B a beginning analysis of the problem
C overall layout or structure of the solution;
D a language like solution
Answer Correct Option D
Marks 2
Unit 1

Id 7
Question ---------------shows the relationship between the modules and the data needed for the
modules.
A coupling diagram and Data Dictionary
B IPO chart
C interactivity chart
D pseudo code
Answer Correct Option A
Marks 2
Unit 1

Page 2
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 8
Question Identify the correct sequence of problem analysis chart.
A 1)Given Data, 2)Solution Alternatives,3)Processing Required , 4)Required Results
B 1) Given Data, 2) Required Results , 3) Processing Required , 4)Solution Alternatives
C 1)Processing Required, 2) Required Results , 3)Given Data, 4)Solution Alternatives
D 1) Given Data, 2) Required Results , 3) Solution Alternatives, 4)Processing Required
Answer Correct Option B
Marks 2
Unit 1

Id 9
Question In interactivity chart Dark circle • on module link shows
A module is part of a set but that are not processed many times
B module is not a part of set that are processed many times & in a loop.
C module is part of a set that are processed many times & in a loop.
D None of these
Answer Correct Option C
Marks 2
Unit 1

Id 13
Question arrange the essential data items for IPO Chart in correct order
A 1)Output 2)Processing 3)Module Reference 4)Input
B 1)Input 2)Module 3) Processing Reference 4)Output
C 1)Input 2)Processing 3)Module Reference 4)Output
D None of these
Answer Correct Option C
Marks 4
Unit 1
Id Keep it blank

Id 10
Question If max is a function that returns the larger of the two integers, given as arguments,
then which of the following statements finds the largest of three given numbers
A max(max(a,b),max (a,c))
B max(max(a,b),max (b,c))
C max(b,max (a,c))
D All of these
Answer Correct Option D
Marks 4

Page 3
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 11
Question A function can make…………..
A One throw
B One throw of each scale type
C One throw of each programmer defined type
D As many throws of as many types as necessary
Answer Correct Option D
Marks 2
Unit 1

Id 12
Question Consider the function
find ( int x, int y)
{
return (( x < y ) ? 0 : ( x - y ));
}
Let a, b be two non-negative integers.
The call find{ a, find(a, b)} can be used to find the
A maximum of a,b
B positive difference of a,b
C sum of a,b
D minimum of a,b
Answer Correct Option D
Marks 4
Unit 1

Id 13
Question Let a, b be two non-negative integers. Which of the following calls, finds the positive
difference of a and b ?
A find(a,b) + find(b,a)
B find(a, find(a,b))
C a + find(a,b)
D b + find(a,b)
Answer Correct Option A
Marks 4
Unit 1

Id 14
Question The default parameter passing mechanism is
A call by value

Page 4
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B call by reference
C call by value result
D none of the above
Answer Correct Option A
Marks 2
Unit 1

Id 15
Question Use of functions
A helps to avoid repeating a set of statements many times
B enhances the logical clarity of the program
C helps to avoid repeated programming across programs
D all of the above
Answer Correct Option D
Marks 2
Unit 1

Id 15
Question Pick the correct statements
A The body of a function should have only one return statement
B The body of a function may have many return statements
C A function can return only one value to the calling environment
D Both (b) and (c )
Answer Correct Option D
Marks 2
Unit 1

Id 16
Question Forward declaration is absolutely necessary
A if a function returns a non integer quantity
B lithe function call precedes its definition
C if the function call precedes its definition and the function returns a non integer
quantity
D none of the above
Answer Correct Option C
Marks 2
Unit 1

Id 17
Question void can be used…………
A as a data type of a function that returns nothing to its calling environment

Page 5
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B inside the brackets of a function that does not need any argument
C in an expression
D Both (a) and (b)
Answer Correct Option D
Marks 2
Unit 1

Id 18
Question Any C++ program
A must contain at least one function
B need not contain any function
C needs input data
D none of these
Answer Correct Option A
Marks 1
Unit 1

Id 19
Question In a certain language, the expression 5-3+2 x 4+1, evaluates to 0. Which of the
following conclusions about the precedence and associativity of the operators +, -, *
are correct?
A + has precedence over - and - has precedence over *
B All these have equal precedence and associate to the right
C All these have equal precedence and associate to the left
D + and – have equal precedence, which is over * and all associate to the left
Answer A
Marks 2
Unit 1

Id 20
Question Which of the following comparison between static and dynamic type checking is
Incorrect?
A Dynamic type checking slows down execution
B Dynamic type checking offers more flexibility to the programmers
C Dynamic type checking is more reliable
D Dynamic type checking is done during compilation, unlike static type checking
Answer A
Marks 2
Unit 1

Id 21

Page 6
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question The period of time between an allocation and its subsequent disposal is called
A Scope
B (dynamic) binding
C Lifetime
D Longevity
Answer C
Marks 2
Unit 1

Id 22
Question Consider the following sequence of statements
Statement 1: A := B+C
Statement 2: D := A+C
Statement 3: E := A+B
Statement 4: G := D-E
Statement 5: H := E+A
Statement 6: I := H+G
Which of the statements can be executed in parallel?

A 2 and 4
B 4 and 5
C 5 and 6
D 4, 5 and 6
Answer A
Marks 2
Unit 1

Id 23
Question If instructions are executed in parallel, whenever the required operands are
available, then the execution time of the previous problem is logically same as that of
sequential algorithm consisting of
A 3 statements
B 2 statements
C 4 statements
D 5 statements
Answer C
Marks 2
Unit 1

Id 24
Question
A recursive function f(x), is defined as follows:
if(x>100)
return(x-10)
else return(f(f(x+11)))
For which of the values of x, f(x) = 91?

Page 7
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

A 100
B 91
C 1
D 101
Answer A
Marks 2
Unit 1

Id 25
Question English language uses full stop as a sentence, while C++ uses ……….
A Separator
B Terminator
C Delimiter
D All of the above
Answer B
Marks 2
Unit 1

Id 26
Question The ASCII (American Standard Code for Information Interchange) character set
contains ------------- characters.
A 652
B 562
C 256
D 265
Answer C
Marks 2
Unit 1

Id 27
Question The character data set, sometimes called alphanumeric data set, consists of all------
A a, A
B A, Z
C #, &
D a, A, Z, 3, #, &
Answer D
Marks 2
Unit 1

Id 33
Question Character data or string data can be joined together with the + operator in an

Page 8
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

operation called-----------
A Palindrome
B Join
C Reverse String
D concatenation
Answer D
Marks 1
Unit 1

Id 34
Question When two pieces of character data are joined, the concatenation results in “4” + “4”
= ? (Replace? With suitable option)
A “44”
B 8
C “8”
D 4+4
Answer A
Marks 2
Unit 1

Id 35
Question Identify the data type for following data set : The price of an Item: 7.39, 12.98
A Numeric: real
B Character string
C Numeric: integer
D Logical
Answer A
Marks 1
Unit 1

Id 36
Question Identify the data type for following data set : An account number: “A2453,” “2987”
A Numeric: real
B Character string
C Numeric: integer
D Logical
Answer B
Marks 2
Unit 1

Id 37

Page 9
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question Identify the data type for following data set :A quantity:12389
A Numeric: real
B Numeric: integer
C Reverse String
D Logical
Answer B
Marks 1
Unit 1

Id 38
Question Identify the data type for following data set :A credit check: True, False
A Numeric: real
B Numeric: integer
C Logical
D Character string
Answer C
Marks 1
Unit 1

Id 39
Question Choose the correct syntax for defining the function
A Function(Data);
B DefineFunction(value)
C FunctionName(Value)

D FunctionName(Value)
Answer C
Marks 1
Unit 1

Id 40
Question Absolute value, or a random number are belongs to which function type?
A Mathematical functions
B String functions.

C Conversion functions.
D Statistical functions.
Answer A
Marks 1
Unit 1

Id 41

Page 10
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question Unrestricted use of goto is harmful because


A It makes debugging difficult
B It increase the running time of program
C It increase memory requirements of program
D It result in the compiler generating longer machine code
Answer Correct option A
Marks 1
Unit 1

Id 42
Question The recurrence relation that arises in relation with the complexity of binary search
is
A T(n)=T(n/2)+k, where k is constant
B T(n)=2T(n/2)+k, where k is constant
C T(n)=T(n/2)+log(n)
D T(n)=T(n/2)+n
Answer Correct option A
Marks 1
Unit 1

Id 43
Question Which of the following algorithm design technique is used in the quick sort
algorithm
A Dynamic programming
B Backtracking
C Divide & conquer
D Greedy method
Answer Correct option C
Marks 1
Unit 1

Id 44
Question Literal means
A a string
B a string constant
C a character
D an alphabet
Answer Correct Option B
Marks 2
Unit Unit 1

Page 11
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 45
Question The value of an automatic variable that is declared but not initialized will be
A 0
B -1
C unpredictable(garbage value)

D none of these
Answer Correct Option C
Marks 2
Unit Unit 1

Id 46
Question Which of the following is true of external variables?
A they provide a way for two way communication between functions
B their scope extends from the point of definition through the remainder of the
program
C if they are not initialized, they will be initilised to zero
D All of these
Answer Correct Option D
Marks 2
Unit Unit 1

Id 47
Question The declaration
int x : 4;
means
A x is a four digit integer
B x cannot be greater than a four digit integer
C x is a four-bit integer
D none of these
Answer Correct Option C
Marks 4
Unit Unit 1

Id 48
Question What is the correct way to round off x from a float, to an int value?

A y=(int) (x+0.5)
B y=int (x+0.5)
C y=(int) x+0.5
D y=(int)(int) x+0.50
Answer Correct Option A
Marks 4
Unit Unit 1

Page 12
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id Keep it blank
Question By default, any real number in 'C' is treated as ……..
A A float
B A double
C A long double
D Depends on the memory model you are using
Answer Correct Option B
Marks 2
Unit Unit 1

Id 49
Question To print out a and b given below, which printf() statement would you use?
float a = 3.14;
double b = 3.14;
A printf("%f%f",a,b);
B printf("%Lf%f",a,b);
C printf("%f%Lf",a,b);
D printf("%Lf%Lf",a,b);
Answer Correct Option A
Marks 4
Unit Unit 1

Id 50
Question In the following 'C' code, in which order the functions would be called ?
a = ( f1(23,14 ) * f2 (12/14)) + f3 () ;
A f1,f2,f3
B f3,f2,f1
C The order may vary from compiler to compiler
D None of these
Answer Correct Option A
Marks 4

Unit Unit 1

Id 51
Question Which one of the following is not the step in ensuring best decision
A Identify the problem.
B Understand the problem.
C Discard the problem & solution
D Evaluate the solution.
Answer C
Marks 2

Page 13
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 52
Question Solutions that cannot be reached through a direct set of steps are called..........
A algorithmic solutions.
B alternative Solution
C heuristic solutions.
D straightforward Solution
Answer C
Marks 2
Unit 1

Id 53
Question A problem that can be solved with a series of actions is called............
A Heuristic solutions.
B Algorithmic solutions.
C straightforward Solution
D alternative Solution
Answer B
Marks 2
Unit 1

Id 54
Question A heuristic type of problems is called..........
A Operation Research

B Artificial intelligence
C Fuzzy Logic
D None of these
Answer B
Marks 2
Unit 1

Id 55
Question The.................... steps in problem solving lead to the best possible solution to a
problem.
A Six
B Four
C Five
D Seven
Answer A
Marks 1

Page 14
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 56
Question The..................solutions are reached in a series of steps.
A algorithmic solutions
B heuristic solutions
C Artificial intelligence
D straightforward Solution
Answer A
Marks 1
Unit 1

Id 57
Question The...................... solutions are attained through trial and error.
A straightforward Solution
B alternative Solution
C algorithmic solutions.
D heuristic solutions.
Answer D
Marks 1
Unit 1

Id 58
The programmer defines each .............and ............... in a problem solution as a
Question particular data type
A Pointer , Array
B Integer , Double
C String , Float
D constant , variable
Answer D
Marks 1
Unit 1

Id 59
Question Variable also known as .....
A Font
B Constant
C Identifier
D File
Answer C
Marks 1

Page 15
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 60
Question A constant is a value that never changes during the processing of all the instructions
in a solution
A FALSE
B None of these
C TRUE
D Both A &C
Answer D
Marks 1
Unit 1

Id 61
Question In UML Sequence diagram used to indicate----------

A to create a logical model of your solution


B how a system functions from the user‟s standpoint
C describe how a class functions
D interactivity between objects
Answer D
Marks 2
Unit 1

Id 62
Question In UML Use case diagrams Used to indicate----------
A how a system functions from the user‟s standpoint
B to create a logical model of your solution
C describe how a class functions
D interactivity between objects
Answer A
Marks 2
Unit 1

Id 63
Question In UML Class diagrams Used to indicate----------
A describe how a class functions
B how a system functions from the user‟s standpoint
C to create a logical model of your solution
D interactivity between objects
Answer A
Marks 2

Page 16
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 64
Question Two main measures for the efficiency of an algorithm are
A Processor and memory
B Complexity and Capacity
C Time and Space
D Data and Space
Answer C
Marks 2
Unit 1

Id 65
Question The time factor while determining the efficiency of algorithm is measured by
A Counting microseconds
B Counting the number of key operations
C Counting the number of statements
D Counting the kilobytes of algorithm
Answer B
Marks 2
Unit 1

Id 66
Question The worst case occur in linear search algorithm when
A Item is somewhere in the middle of the array
B Item is not in the array at all
C Item is the last element in the array
D Item is the last element in the array or is not there at all
Answer D
Marks 2
Unit 1

Id 67
Question In case of ordinary int variables
A leftmost bit is reserved for sign
B rightmost bit is reserved for sign
C no bit is reserved for sign
D none of these
Answer A
Marks 2

Page 17
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 68
Question The variables which can be accessed by all modules in a program are known as

A Local variables
B Internal variables
C External variables
D Global variables
Answer Correct Option (D)
Marks 2
Unit 1

ID 69
Question The basic unit of information is the
A Byte
B Bit
C Block
D Sector
Answer B
Marks 2
Unit 1

ID 70
Question The most widely used method for interpreting bit setting as nonnegative integer is
the
A Octal number system
B ASCII
C ANS!
D Binary number system
Answer D
Marks 2
Unit 1

ID 71
Question The method used by the computers to represent real number is
A Floating-point notation
B Mantissa
C ANSI
D Binary number system
Answer D
Marks 2

Page 18
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

ID 72
Question The variable which can be accessed by all modules in a program, are known as
A Local variable
B Internal variable
C External variable
D Global variable
Answer D
Marks 2
Unit 1

ID 73
Question In which kind of storage structure for string , one can easily insert ,delete,
concatenate ,and rearrange substring?
A Fixed length storage structure
B Variable length storage structure
C Linked list storage
D Array type storage
Answer C
Marks 2
Unit 1

ID 74
Question Which of the following sorting procedure is the slowest ?
A Quick sort
B Heap sort
C Shell sort
D Bubble sort
Answer B
Marks 2
Unit 1

ID 75
Question The smallest element of an array‟s index is called its

A Lower bound
B Upper bound
C Range
D Extraction
Answer A

Page 19
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Marks 2
Unit 1

ID 76
Question The preliminary evaluation of a top-down design before programs are written is
referred to as a (an)
A Informal design review
B Structured walk through
C formal design review
D Scheduled review
Answer A
Marks 2
Unit 1

ID 77
Question Which of the following is not an example of program documentation
A Source code
B Object code
C Specification
D Identifier names
Answer B
Marks 1
Unit 2

ID 78
Question Which of the following is non-essential to stepwise refinement?
I. Refining the subprogram
II. Decomposing the problem into subprograms
III. Declaring all variables
IV. Stating the problem simply
V. Inputing the data

A 2
B 3 and 4
C 4 and 5
D 5
Answer D
Marks 4
Unit 1

ID 79
Question A top-down approach to programming calls for
1. Working from the general to the specific

Page 20
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

2. Postponing the minor decisions


3. A systematic approach
4. Immediate coding of the problem

A 1
B 1 and 2
C 1,2 and 3
D 1,2 and 4
Answer C
Marks 4
Unit 1

ID 80
Question Repeated execution of simple computation of
A Round-off errors
B Syntax errors
C Run-time errors
D Logic errors
Answer A
Marks 2
Unit 1

ID 81
Question Which of the following boolean expression is true?
A 2*2+3=10
B (2.4)and not(4.3)
C (5.6)or(3 div 3 = 1)
D -7 * 2 + 2 * 7 = 1
Answer C
Marks 2
Unit 1

id 82
Question In C++ programming language, which of the following type of operators have the
highest precedence
A Relation operators
B Equality operators
C Logical operators
D Arithmetic operators
Answer D
Marks 2
Unit 1

Page 21
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

196 83
Question In C++ programming language, which of the following operators has the highest
precedence
A Unary +
B *
C ≥
D ==
Answer A
Marks 2
Unit 1

197 84
In C++ programming language, if the first and the second operands of operator + are
Question of types int and float,respectively,the result will be of type
A int
B float
C char
D Long int
Answer B
Marks 2
Unit 1

199 85
Question In C++ language, the bitwise operators can be applied to which of the following
operands
A char
B Short,long
C Int
D All of the above
Answer D
Marks 2
Unit 1

Id 86
Question Consider the n elements are to be sorted. what is the worst case time complexity of
20 bubble sort?
A O(1)
B O(log2 n)
C O(n)
2
D O(n )
Answer Correct Option (D)

Page 22
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Marks 4
Unit 1

Id 87
Question Consider that n elements are to be sorted. What is the worst case time complexity of
21 shell sort?
A O(n)
B O(n log2 n)

C O(n1.2)
D O(n)

Answer Correct Option (C)


Marks 4
Unit 1

Id 88
Question What is the worst case time Complexity of straight insertion sort algorithm to sort n
22 elements
A O (n)
B O (n Log2 n)

C O(n1.2)
D O(n2)
Answer Correct Option(D)
Marks 4
Unit 1

Id 89
Question What is the worst space time complexity of binary insertion sort algorithm to sort n
23 elements
A O(n)
B O(n log2 n)

C O(n1.2)
D O(n2)
Answer Correct Option (D)
Marks 4
Unit 1

Id 90
Question 25 Which of the following sorting procedure in the slowest?
A Quick sort
B Heap sort
C Shell sort

Page 23
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

D Bubble sort
Answer Correct option (D)
Marks 2
Unit 1

Id 91
Question In a 'C++' expression involving || operator, evaluation
A Will be stopped if one of its components evaluates to false
B Will be stopped if one of its components evaluates to true
C Takes place from right to left
D Will be stopped if both of its components evaluates to true
Answer Correct Option B
Marks 2
Unit 1

Id 92
Question In C programming language, which of the following type of operators have the
highest precedence
A Relational Operators
B Equality Operators
C Logical Operators
D Arithmetic Operators
Answer Correct Option D
Marks 2
Unit 1

Id 93
Question In C programming language, which of the following operators has the highest
precedence?
A Unary +
B *
C >=
D Equals (==)
Answer Correct Option A
Marks 2
Unit 1

Id 94
Question Which of the following operators takes only integer operands ?
A +
B *

Page 24
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C /
D %
Answer Correct Option D
Marks 2
Unit 1

Id 95
Question In an operation involving || operator, evaluation
A takes palce from left to right
B Will be stopped if one of its components evaluates to true
C Takes place from right to left
D Both (a) and (b)
Answer Correct Option D
Marks 2
Unit 1

Id 96
Question Pick the operators that associate from the left
A +
B ,
C <
D All the above
Answer Correct Option D
Marks 2
Unit 1

Id 97
Question The operators . , || , < , = , if arranged in the ascending order of precedence reads
A . , || , < , =
B (=, < , ||, .)
C (=, || , < , .)

D (< , || , = , .)
Answer Correct Option C
Marks 2
Unit 1

Id 98
Question The expression 4 + 6 / 3 * 2 - 2 + 7 % 3 evaluates to
A 3
B 5

Page 25
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C 6
D 7
Answer Correct Option D
Marks 4
Unit 1

Id 99
Question Which of the following sorting algorithm is stable
A insertion sort.
B bubble sort.
C quick sort.
D heap sort.
Answer Correct Option D
Marks 2
Unit 1

Id 100
Question The number of elements that can be sorted in Θ(logn) time using heap sort is
A Θ(1)
B Θ(√logn)
C Θ(√logn)
D Θ(logn)
Answer Correct Option A
Marks 2
Unit 1

Id 101
Question A sort which relatively passes through a list to exchange the first element with any
element less than it and then repeats with a new first element is called
A Insertion sort
B Selection sort
C Heap sort
D Quick sort
Answer Correct Option D
Marks 2
Unit 1

Id 102
Question A sorting technique which uses the binary tree concept such that label of any node is
larger than all the labels in the subtrees, is called
A Selection sort

Page 26
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B Insertion sort
C Insertion sort
D Quick sort
Answer Correct Option C
Marks 2
Unit 1

Id 103
Question A sort which uses binary tree concept such that any number is larger than all the
numbers in the subtree below it,is called
A Selection sort
B Insertion sort
C Heap sort
D Quick sort
Answer Correct Option C
Marks 2
Unit 1

Id 104
Question Which sorting algorithm uses the median-of-3 partitioning?
A heap sort

B merge sort
C quick sort
D Shell sort
Answer Correct Option
Marks 2
Unit 1

Id 105
Question Which data type is not a primary data type?
A int
B array
C float
D char
Answer Correct Option B
Marks 1
Unit 1

Id 106
Question How much memory is required to store a value of type double
A 4bytes

Page 27
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B 6 bytes
C 8 bytes
D 10 bytes
Answer Correct Option C
Marks 1
Unit 1

Id 107
Question The modifier which is used to declare a variable as constant
A short
B signed
C unsigned
D const
Answer Correct Option D
Marks 1
Unit 1

Id 108
Question A declaration "short int" is used for variables
A which have a short duration in a program
B which have short names
C which may require less storage than normal integer
D all of these
Answer Correct Option C
Marks 1
Unit 1

Id 109
Question 5 The number of swapping needed to sort the number 8,12,7,9,31,19,5,13 in ascending
order, using bubble sort is
A 11
B 12
C 13
D 14
Answer D
Marks 4
Unit 1

Id 110
Question 6 Given 2 sorted list of size „m‟ and „n‟ respectively. The number of comparisons needed
in the worst case by the merge sort algorithm will be

Page 28
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

A mn
B max (m,n)
C min (m,n)
D M+n-1
Answer B
Marks 4
Unit 1

Id 111

A hash table with 10 buckets with one slot per bucket is depicted. The symbols, S1 to
Question 8 S7 are initially entered using a hashing function with linear probing. The maximum
number of comparisons needed in searching an item that is not present is
A 4
B 5
C 6
D 3
Answer B
Marks 4
Unit 1

Id 112
Question 9 A binary tree in which every non-leaf node has non-empty left and right sub-trees is
called a strictly binary tree. Such a tree with 10 leaves
A Cannot have more than 19 node
B Has exactly 19 nodes
C Has exactly 17 nodes
D Cannot have more than 17 nodes
Answer A
Marks 4
Unit 1

Id 113
Question 87 The variables which can be accessed by all modules in a program, are called
A local variables
B internal variables
C external variables
D global variable
Answer D
Marks 2
Unit 1

Page 29
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 114
Question 90 A static variable
A cannot be initialized
B is initialized once at the commencement of execution and cannot be changed at run
time

C retains its value throughout the file of the program


D is same as an automatic variable but is placed at the head of the program
Answer C
Marks 2
Unit 1

Id 115
Question 31 To find the length or the number of characters in the string, which function type you
will use?
A String Functions
B Mathematical functions.
C Conversion functions.
D Statistical functions.
Answer A
Marks 1
Unit 1

Id 116
Question 32 Match the Definitions from given options, for the function Sqrt(N)
A Returns the absolute value of N
B Returns the square root of N.
C Returns the rounded value of N to the n1 place.
D Returns a random number between 0 and 1
Answer B
Marks 2
Unit 1

Id Keep it blank
Question 33 Match the Definitions from given options, for the function Abs(N)
A Returns the square root of N.
B Returns the absolute value of N.
C Returns the rounded value of N to the n1 place.
D Returns a random number between 0 and 1
Answer B
Marks 2
Unit 1

Page 30
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .40

Id 117
Question 34 If we use function Integer (5.7269) then what will be the result it will return.
A 5.72
B 5.7269
C 5
D 5.7
Answer C
Marks 4
Unit 1

Id 118
Question 35 If we use function Abs (-3)then what will be the result it will return.
A -3
B -3
C 3
D A3.0
Answer C
Marks 4
Unit 1

Id 119
Question Replace blank space with suitable option :- ----------- are used to calculate things
such as maximum values, minimum values, and so forth..
A Statistical functions.
B Mathematical functions.
C String functions.
D Conversion functions
Answer A
Marks 1
Unit 1

Id 120
Question Select appropriate definition from given options for the function Value(S)
A Changes a string value into a numeric value.
B Changes a numeric value into a string value.

Page 31
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

DEPARTMENT OF COMPUTER ENGINEERING , MATOSHRI COLLEGE OF ENGINEERING & R.C. NASHIK , PAGE NO. .41

C Returns the average of a list of numbers.


D Returns the maximum value from a list of numbers.
Answer A
Marks 2
Unit 1

Id 121
Question Select appropriate definition from given options for the function String(N)
A Changes a string value into a numeric value.
B Changes a numeric value into a string value.
C Returns the average of a list of numbers.
D Returns the maximum value from a list of numbers..
Answer B
Marks 2
Unit 1

Id 122
Question Which of the following sorting algorithms does not have a worst case running time of
o(n2)
A Insertion sort
B Merge sort
C Quick sort
D Bubble sort
Answer Correct Option (B)
Marks 2
Unit 1

Id 123
Question Identify the operator & operand from given expression 5 + 7
A 5 and 7 are operator, + is the operand
B 5 is operator & 7 is operand
C + is the operator, 5 and 7 are the operand
D None of these
Answer C
Marks 1
Unit 1

Page 32
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Id 124
Question Calculate the resultant for the operation like 9 MOD 4
A 2
B 0.44
C 2.25

D 1
Answer D
Marks 2
Unit 1

Id 125
Question Choose the correct resultant for the logical operation like:- True AND True
A TRUE
B FALSE
C Both A&B
D None of these
Answer A
Marks 2
Unit 1

Id 126
Question Construct the expression for”a 40-hour work week and overtime pay at 1.5 times
regular pay, calculated overtime pay would subtract 40 from the hours worked and
multiply the result by the regular wage times 1.5”
A (Hours-40)*Wage*1.5
B (Wage-40)*Hours*1.5
C (Hours-1.5)*Wage*40
D (Overtime-40)*Regular Pay*1.5
Answer A
Marks 2
Unit 1

Id 127
Question --------------------refers to the rules governing the computer operating system, the
language, and the application.
A Bug.
B Syntax
C Debugging.
D Testing
Answer B
Marks 2

Page 33
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 128
Question Problem analysis chart shows -----------------
A input, the processing, and the output;
B overall layout or structure of the solution;
C a beginning analysis of the problem
D a language like solution
Answer C
Marks 1
Unit 1

Id 129
Question Which of the following case does not exist in complexity theory?
A Best case
B Worst case
C Average case
D Null case
Answer D
Marks 1
Unit 1

Id 130
Question The complexity of linear search algorithm is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer A
Marks 1
Unit 1

Id 131
Question The complexity of Binary search algorithm is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer B
Marks 1
Unit 1

Id 132
Question The complexity of merge sort algorithm is
A O(n)
B O(log n)
C O(n2)

Page 34
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

D O(n log n)
Answer D
Marks 1
Unit 1

Id 133
Question The complexity of Bubble sort algorithm is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer C
Marks 1
Unit 1

Id 134
Question The Worst case occur in linear search algorithm when
A Item is somewhere in the middle of the array
B Item is not in the array at all
C Item is the last element in the array
D Item is the last element in the array or is not there at all
Answer D
Marks 1
Unit 1

Id 135
Question The worst case complexity for insertion sort is
A O(n)
B O(log n)
C O(n2)
D O(n log n)
Answer C
Marks 1
Unit 1

Id 136
Question The complexity of Fibonacci series is
A O(2n)
B O(log n)
C O(n2)
D O(n log n)
Answer A
Marks 1
Unit 1

Id 137
Question If f(x) = 3x2 + x3logx, then f(x) is
A O(x2)
B O(x3)

Page 35
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C O(x)
D O(1)
Answer B
Marks 1
Unit 1

Id 138
Question The big-O notation for f(n) = (nlogn + n2)(n3 + 2) is
A O(n2)
B O(3n)
C O(n4)
D O(n5)
Answer D
Marks 1
Unit 1

Id 139
Question The big-O notation for f(n) = 2log(n!) + (n2 + 1)logn is
A n
B n2
C nlogn
D n2logn
Answer D
Marks 1
Unit 1

Id 140
Question The big-theta notation for function f(n) = 2n3 + n – 1 is
A n
B n2
C n3
D n4
Answer C
Marks
Unit

Id 141
Question The big-theta notation for f(n) = nlog(n2 + 1) + n2logn is
A n2logn
B n2
C logn
D nlog(n2)
Answer A
Marks 1
Unit 1

Id 142
Question The big-omega notation for f(x, y) = x5y3 + x4y4 + x3y5 is
A x5y3

Page 36
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

B x5y5
C x3y3
D x4y4
Answer C
Marks 1
Unit 1

Id 143
Question If f1(x) is O(g(x)) and f2(x) is o(g(x)), then f1(x) + f2(x) is
A O(g(x))
B o(g(x))
C O(g(x)) + o(g(x))
D None of these
Answer A
Marks 1
Unit 1

Id 144
Question The big-O notation for f(x) = 5logx is
A 1
B X
C X2
D X3
Answer B
Marks 1
Unit 1

Id 145
Question Which if the following is/are the levels of implementation of data structure
A Abstract level
B Application level
C Implementation level
D All of the above
Answer D
Marks 1
Unit 1

Id 146
Question ……………….. level is where the model becomes compatible executable code
A Abstract level
B Application level
C Implementation level
D All of the above
Answer C
Marks 1
Unit 1

Id 147
Question Stack is also called as

Page 37
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

A Last in first out


B First in last out
C Last in last out
D First in first out
Answer A
Marks 1
Unit 1

Id 148
Which of the following is true about the characteristics of abstract data types?
i) It exports a type.
Question ii) It exports a set of operations
A True, False
B False, True
C True, True
D False, False
Answer C
Marks 1
Unit 1

Id 149
Question …………… is not the component of data structure.
A Operations
B Storage Structures
C Algorithms
D None of above
Answer D
Marks 1
Unit 1

Id 150
Question Which of the following is not the part of ADT description?
A Data
B Operations
C Both of the above
D None of the above
Answer D
Marks 1
Unit 1

Id 151
Inserting an item into the stack when stack is not full is called …………. Operation
and deletion of item form the stack, when stack is not empty is called
Question ………..operation.
A push, pop
B pop, push
C insert, delete
D delete, insert
Answer A
Marks 2

Page 38
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Unit 1

Id 152
……………. Is a pile in which items are added at one end and removed from the
Question other.
A Stack
B Queue
C List
D None of the above
Answer B
Marks 1
Unit 1

Id 153
………… is very useful in situation when data have to stored and then retrieved in
Question reverse order.
A Stack
B Queue
C List
D Link list
Answer A
Marks 1
Unit 1

Id 154
Question Which data structure allows deleting data elements from and inserting at rear?
A Stacks
B Queues
C Dequeues
D Binary search tree
Answer B
Marks 1
Unit 1

Id 155
Which of the following data structure can't store the non-homogeneous data
Question elements?
A Arrays
B Records
C Pointers
D Stacks
Answer A
Marks 1
Unit 1

Id 156
A ....... is a data structure that organizes data similar to a line in the supermarket,
Question where the first one in line is the first one out.
A Queue linked list
B Stacks linked list

Page 39
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

C Both of them
D Neither of them
Answer A
Marks 1
Unit 1

Id 157
Identify the data structure which allows deletions at both ends of the list but
Question insertion at only one end.
A Input-restricted deque
B Output-restricted deque
C Priority queues
D None of above
Answer A
Marks 1
Unit 1

Id 158
Question Which of the following data structure is non-linear type?
A Strings
B Lists
C Stacks
D None of above
Answer D
Marks 1
Unit 1

Id 159
Question Which of the following data structure is linear type?
A Strings
B Lists
C Queues
D All of above
Answer D
Marks 1
Unit 1

Id 160
To represent hierarchical relationship between elements, which data structure is
Question suitable?
A Deque
B Priority
C Tree
D All of above
Answer C
Marks 1
Unit 1

Id 161

Page 40
Data Structures & Algorithms M.C.Q. BANK, FOR UNIT -1 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN , U.O.P.

Question An algorithm that calls itself directly or indirectly is known as


A Sub algorithm
B Recursion
C Polish notation
D Traversal algorithm
Answer B
Marks 1
Unit 1

Id 162
Question A mathematical-model with a collection of operations defined on that model is called
A Data Structure
B Abstract Data Type
C Primitive Data Type
D Algorithm
Answer B
Marks 1
Unit 1

Page 41
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

UNIT-2
Marks distribution for Unit 2

4 + 4+ 2 +2 +1 = 13 Marks (Only 2 Question will be asked for 4 marks , 2 Questions will be asked for 2
Marks, 1 Question will be asked for 1 Mark )
Syllabus for Unit-2

Sequential Organization, Linear Data Structure Using Sequential Organization, Array as an Abstract
Data Type, Memory Representation and Address Calculation, Inserting an element into an array,
Deleting an element, Multidimensional Arrays, Two-dimensional arrays, n- dimensional arrays, Concept
of Ordered List, Single Variable Polynomial, Representation using arrays, Polynomial as array of
structure, Polynomial addition, Polynomial multiplication, Sparse Matrix, Sparse matrix representation,
Sparse matrix addition, Transpose of sparse matrix, String Manipulation Using Array.
Case Study- Use of sparse matrix in Social Networks and Maps.
Reference Book:
• “Data Structures Using C++”, Varsha H. Patil, ISBN 13-9780198066231
Id 1
What will happen if in a C++ program, you assign a value to an array element whose
Question subscript exceeds the size of array?
A The element will be set to 0.
B The compiler would report an error
C The program may crash if some important data gets overwritten.
D The array size would appropriately grow.
Answer C
Marks 2

Id 2
What does the following declaration mean?
Question int (*ptr)[10];
A ptr is array of pointers to 10 integers
B ptr is a pointer to an array of 10 integers
C ptr is an array of 10 integers
D ptr is an pointer to array
Answer B
Marks 2

Id 3
Question In C++, if you pass an array as an argument to a function, what actually gets passed?
A Value of elements in array
B First element of the array
C Base address of the array
D Address of the last element of array
Answer C
Marks 2

Id 4
What is meaning of following declaration ?
Question int arr[20];

Page 1
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A None of these
B Integer Array of size 20
C Array of Size 20
D Array of size 20 that can have integer address
Answer B
Marks 2

Id 5

int a[20];
What will be the size of above array element ?
Question
A 20
B 19
C 22
D 21
Answer A
Marks 2

Id 6
Question What is meaning of the following statement? int *ptr[20];
A None of these
B Array of Integer Pointers of size 20
C Integer Array to Integer Pointers having size 20
D Integer Array of size 20 pointing to an Integer Pointer
Answer B
Marks 2

Id 7
Question In C++ Programming, If we need to store word "INDIA" then syntax is as below -
char name[]; name = "INDIA";
A
char name[6] = {'I','N','D','I','A'}
B
char name[6] = {"I","N","D","I","A"}
C
char name[6] = {'I','N','D','I','A','\0'}
D
Answer D
Marks 2

Id 8

int RollNum[30][4];
Above is an example of:
Question
A 2-D Array
B 1-D Array
C 3-D Array
D 4-D Array

Page 2
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Answer A
Marks 2

Id 9
What is the output of this C code?
#include <stdio.h>
void main()
{
int a[2][3] = {1, 2, 3, 4, 5};
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
Question }
A 123450
B 1 2 3 4 5 junk
C 123455
D Run time error
Answer A
Marks 4

Id 10
What is the output of this C code?
#include <stdio.h>
void main()
{
int a[2][3] = {1, 2, 3, , 4, 5};
Question
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}
A 1 2 3 junk 4 5
B Compile time error
C 123045
D 123345
Answer B
Marks 4
Unit

Id 11
What is the output of this C code?
#include <stdio.h>
void f(int a[ ][3])
{
a[0][1] = 3;
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}
void main()
Question {

Page 3
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

int a[2][3] = {0};


f(a);
}
A 030000
B Junk 3 junk junk junk junk
C Compile time error
D All junk values
Answer A
Marks 4
Unit

Id 12
What is the output of this C code?
#include <stdio.h>
void f(int a[ ][ ])
{
a[0][1] = 3;
int i = 0, j = 0;
for (i = 0;i < 2; i++)
for (j = 0;j < 3; j++)
printf("%d", a[i][j]);
}
void main()
{
int a[2][3] = {0};
f(a);
Question }
A 030000
B Junk 3 junk junk junk junk
C Compile time error
D All junk values
Answer C
Marks 4
Unit

Id 13
Which of the following statements are correct about 6 used in the program?
int num[6];
Question num[6]=21;
In the first statement 6 specifies a particular element, whereas in the second
A statement it specifies a type.
In the first statement 6 specifies a array size, whereas in the second statement it
B specifies a particular element of array.
In the first statement 6 specifies a particular element, whereas in the second
C statement it specifies a array size.
D In both the statement 6 specifies array size.
Answer B
Marks 2
Unit

Id 14
Which of the following statements are correct about an array?
1: The array int num[26]; can store 26 elements.
Question 2: The expression num[1] designates the very first

Page 4
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

element in the array.


3: It is necessary to initialize the array at the time of
declaration.
4: The declaration num[SIZE] is allowed if SIZE is a
macro.

A 1
B 1,4
C 2,3
D 2,4
Answer B
Marks 2
Unit

Id 15
What will be the output of the program ?
#include<stdio.h>

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
Question }
A 2,1,15
B 1,2,5
C 3,2,15
D 2,3,20
Answer C
Marks 4
Unit

Id 16
Question What will be the output of the program ?
#include<stdio.h>
int main()
{
static int a[2][2] = {1, 2, 3, 4};
int i, j;
static int *p[] = {(int*)a, (int*)a+1, (int*)a+2};
for(i=0; i<2; i++)
{
for(j=0; j<2; j++)
{
printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i),
*(*(i+p)+j), *(*(p+j)+i));
}
}
return 0;
}
1, 1, 1, 1
A 2, 3, 2, 3

Page 5
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

3, 2, 3, 2
4, 4, 4, 4
1, 2, 1, 2
2, 3, 2, 3
3, 4, 3, 4
B 4, 2, 4, 2
1, 1, 1, 1
2, 2, 2, 2
2, 2, 2, 2
C 3, 3, 3, 3
1, 2, 3, 4
2, 3, 4, 1
3, 4, 1, 2
D 4, 1, 2, 3
Answer C
Marks 4
Unit

Id 17
What will be the output of the program ?
#include<stdio.h>
void fun(int **p);

int main()
{
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};
int *ptr;
ptr = &a[0][0];
fun(&ptr);
return 0;
}
void fun(int **p)
{
printf("%d\n", **p);
Question }
A 1
B 2
C 3
D 4
Answer A
Marks 4

Id 18
Question The extra key inserted at the end of the array is called a
A End Key
B Stop Key
C Sentinel
D Transposition
Answer C
Marks 1

Id 19
Question The size of array int a[5]={1,2} is
A 4
B 12

Page 6
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

C 10
D 6
Answer C
Marks 2

Id 20
The output of the following statements is
char ch[6]={„e‟, „n‟, „d‟, „\0‟, „p‟};
Question printf(“%s”, ch);
A endp
B end0p
C end
D error
Answer C
Marks 2

Id 21
Question 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]
Answer A
Marks 1

Id 22
Question 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]
Answer A
Marks 2
Unit

Id 23
What will be the output of the following code segment?
main( ) {
char s[10];
strcpy(s, “abc”);
printf(“%d %d”, strlen(s), sizeof(s));
Question }
A 3 10
B 33
C 10 3
D 10 10
Answer A

Page 7
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Marks 2
Unit

Id 24
Question 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];
cout<< b;
}
A 20
B 25
C 45
D 90
Answer A
Marks 2
Unit

Id 25
Question Sparse matrices have?
A no zero
B many zero
C higher dimension
D none
Answer B
Marks 1
Unit

Id 26
Consider the polynomial p(x) = a0 + a1x + a2x^2 +a3x^3, where ai != 0, for all i. The
Question minimum number of multiplications needed to evaluate p on an input x is:
A 3
B 4
C 6
D 9
Answer A
Marks 2
Unit

Id 27

Page 8
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question Which of the following data structure is linear data structure?


A Trees
B Graphs
C Arrays
D None of above
Answer C
Marks 1
Unit

Id 28
Question The elements of an array are stored successively in memory cells because
by this way computer can keep track only the address of the first element and the
A addresses of other elements can be calculated
the architecture of computer memory does not allow arrays to store other than
B serially
C both of above
D none of above
Answer A
Marks 1
Unit

Id 29
Question
Which of the following data structure is not linear data structure?
A Arrays
B Linked lists
C Both of above
D None of above
Answer D
Marks 1
Unit

Id 30
Question Finding the location of the element with a given value is:
A Traversal
B Search
C Sort
D None of above
Answer B
Marks 1
Unit

Id 31

Page 9
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question Arrays are best data structures


A for relatively permanent collections of data
B for the size of the structure and the data in the structure are constantly changing
C for both of above situation
D for none of above situation
Answer A
Marks 1
Unit

Id 32
Question Each array declaration need not give, implicitly or explicitly, the information about
A the name of array
B the data type of array
C the first data from the set to be stored
D the index set of the array
Answer C
Marks 1
Unit

Id 33
Question Which of the following data structure is non-linear type?

A Strings
B Lists
C Stacks
D Tree
Answer D
Marks 1
Unit 2

Id 34
Question Which of the following data structure is linear type?
A Array
B Tree
C Graphs
D Hierarchy
Answer A
Marks 1
Unit 2

Id 35
Question The logical or mathematical model of a particular organization of data is called a

Page 10
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

.........

A Data structure
B Data arrangement
C Data configuration
D Data formation
Answer A
Marks 1
Unit 2

Id 36

Question The simplest type of data structure is ..................


A Multidimensional array
B Linear array
C Two dimensional array
D Three dimensional array
Answer A
Marks 1
Unit 2

Id 37
Question Arrays are best data structures ............
A For relatively permanent collections of data.
B For the size of the structure and the data in the structure are constantly changing
C For both of above situation
D For none of the above
Answer A
Marks 1
Unit 2

Id 38
Question Which of the following data structures are indexed structures?
A Linear arrays
B Linked lists
C Graphs
D Trees
Answer A
Marks
Unit

Id 39

Page 11
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question Each node in a linked list has two pairs of .............. and ...................
A Link field and information field
B Link field and avail field
C Avail field and information field

D Address field and link field


Answer A
Marks 1
Unit 2

Id 40
Question A ........................ does not keep track of address of every element in the list.
A Stack
B String

C Linear array
D Queue
Answer A
Marks 1
Unit 2

Id 41
Question To implement Sparse matrix dynamically, the following data structure is used
A Trees
B Graphs
C Priority Queues
D Linked List
Answer D
Marks 1
Unit 2

Id 42
Question Sparse matrix has?
A Many zero entries
B Many non-zero entries
C Higher dimension
D None of the above
Answer A
Marks 1
Unit 2

Id 43

Page 12
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

The linked list implementation of sparse matrices is superior to the generalized dope
Question vector method because it is?
A Conceptually easier
B Completely dynamic
C Efficient in accessing an entry
D A and B
Answer D
Marks 1
Unit 2

Id 44
Question An array is a collection of:
A Different data types scattered throughout memory
B Same data types scattered throughout memory
C Same data types placed next to each other in memory
D Different data types placed next to each other in memory
Answer C
Marks 1
Unit 2

Id 45
Question Which of the declaration of array are correct?
A int a(25);
B int size = 10, b[size];
C int c = {0, 1, 2};

D None of the above


Answer D
Marks 1
Unit 2

Id 46
What is the difference between the 5‟s in these two expressions?(Select the correct
option)
int num[5];
Question num[5] = 11;
A First is particular element, second is type
B First is array size, second is particular element
C First is particular element, second is array size
D Both specify array size
Answer B
Marks 2
Unit 2

Page 13
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Id 47
Let A be a square matrix of size n x n. Consider the following program. What is the
expected output?
C = 100
for i = 1 to n do
for j = 1 to n do
{
Temp = A[i][j] + C
A[i][j] = A[j][i]
A[j][i] = Temp - C
}
for i = 1 to n do
for j = 1 to n do
Question Output(A[i][j]);
A The matrix A itself
B Transpose of matrix A
Adding 100 to the upper diagonal elements and subtracting 100 from diagonal
C elements of A
D None of the above
Answer A
Marks 4
Unit 2

Id 48
The minimum number of arithmetic operations required to evaluate the polynomial
Question P(X) = X5 + 4X3 + 6X + 5 for a given value of X using only one temporary variable.

A 6
B 7
C 8
D 9
Answer B
Marks 2
Unit 2

Id 49
Consider the following C++ function in which size is the number of elements in the
array E:
The value returned by the function MyX is the
int MyX(int *E, unsigned int size)
{
int Y = 0;
int Z;
int i, j, k;

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


Y = Y + E[i];

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


for (j = i; j < size; j++)
{
Question Z = 0;

Page 14
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

for (k = i; k <= j; k++)


Z = Z + E[k];
if (Z > Y)
Y = Z;
}
return Y;
}
A maximum possible sum of elements in any sub-array of array E.
B maximum element in any sub-array of array E.
C sum of the maximum elements in all possible sub-arrays of array E
D the sum of all the elements in the array E.
Answer A
Marks 4
Unit 2

Id 50
If array A is made to hold the string “abcde”, which of the following four test cases
will be successful in exposing the flaw in this procedure?
(1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
Question (4) oldc = "abc", newc = "bac"
A None
B 2 only
C 3 and 4 only
D 4 only
Answer C
Marks 4
Unit 2

Id 51
A program P reads in 500 integers in the range [0..100] representing the scores of
500 students. It then prints the frequency of each score above 50. What would be the
Question best way for P to store the frequencies?
A An array of 50 numbers
B An array of 100 numbers
C An array of 500 numbers
D A dynamically allocated array of 550 numbers
Answer A
Marks 4

Unit 2

Id 52
Consider the following C++ program that attempts to locate an element x in an
array Y[] using binary search. The program is erroneous.
f(int Y[10], int x) {
int i, j, k;
Question i = 0; j = 9;

Page 15
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

do {
k = (i + j) /2;
if( Y[k] < x) i = k; else j = k;
} while(Y[k] != x && i < j);
if(Y[k] == x) cout<<"x is in the array " ;
else cout<<" x is not in the array " ;
}
On which of the following contents of Y and x does the program fail?
A Y is [1 2 3 4 5 6 7 8 9 10] and x < 10
B Y is [1 3 5 7 9 11 13 15 17 19] and x < 1
C Y is [2 2 2 2 2 2 2 2 2 2] and x > 2
D Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even
Answer C
Marks 4
Unit 2

Id 53
Consider the following C++ program that attempts to locate an element x in an
array Y[] using binary search. The program is erroneous.
f(int Y[10], int x) {
int i, j, k;
i = 0; j = 9;
do {
k = (i + j) /2;
if( Y[k] < x) i = k; else j = k;
} while(Y[k] != x && i < j);
if(Y[k] == x) cout<<"x is in the array " ;
else cout<<" x is not in the array " ;
}
Question What is the correction needed in the program to make it work properly?
A Change line 6 to: if (Y[k] < x) i = k + 1; else j = k-1;
B Change line 6 to: if (Y[k] < x) i = k - 1; else j = k+1;
C Change line 6 to: if (Y[k] <= x) i = k; else j = k;
D Change line 7 to: } while ((Y[k] == x) && (i < j));
Answer A
Marks 4
Unit 2

Id 54
A set X can be represented by an array x[n] as follows:

Consider the following algorithm in which x,y and z are Boolean arrays of size n:
algorithm zzz(x[] , y[], z [])
{
int i;
for (i=O; i<n; ++i)
z[i] = (x[i] ^ ~y[i]) V (~x[i] ^ y[i])
}
Question The set Z computed by the algorithm is:

Page 16
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A (X Intersection Y)
B (X Union Y)
C (X-Y) Intersection (Y-X)
D (X-Y) Union (Y-X)
Answer D
Marks 4
Unit 2

Id 55
Question Array name indicates________
A Just the name of array

B Address of starting element


C Value of starting element
D None of the above
Answer B
Marks 1
Unit 2

Id 56
Question The array subscript always start at ________
A 1
B -1
C 0
D Any position
Answer C
Marks 1
Unit 2

Id 57
Question Array elements occupy______
A Varying length of memory locations for each element
B Subsequent memory locations
C Random memory locations
D None of these
Answer B
Marks 1
Unit 2

Id 58
Question In arrays ______ and ______ are difficult but ______ is easy operation.

Page 17
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A Insertion, deletion, searching


B Searching, insertion, deletion
C Deletion, searching, insertion
D None of these.
Answer A
Marks 2
Unit 2

Id 59
What is the output for following program?
void main()
{
int a[5]={3,4};
cout<<a[2]<<a[3]<<a[4];
Question }
A 211
B Garbage value
C 122
D 000
Answer D
Marks 1
Unit 2

Id 60
What is the output for following program?
void main()
{
int i=0,a[3];
a[i] = i++;
cout<<a[i];
Question }
A Garbage value
B Syntax error
C 1
D 0
Answer A
Marks 1
Unit 2

Id 61
Question In Linked list, the logical order of elements ________
A Is determined by their physical arrangement
B Cannot be determined by their physical arrangement
C Is the same as their physical arrangement
D None of these.

Page 18
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Answer B
Marks 1
Unit 2

Id 62
Question In CLL, insertion of a record involves modification of……
A 1 pointer
B 2 pointers
C No pointer
D 3 pointers
Answer B
Marks 2
Unit 2

Id 63
Question For traversing a list, which pointer do you need?
A NULL
B Insertion
C Beginning
D Walking
Answer C
Marks 1
Unit 2

Id 64
Question The nth node in SLL, is accessed via ________
A Tail node
B Head node
C (n-1) nodes
D None of these
Answer B
Marks 1
Unit 2

Id 65
What is the output of this c++ code?
void main()
{
int a[2][3] = {1,2,3,4,5}
int i=0,j=0;
for(i=0 ; i<2 ; i++)
for(j=0 ; j<3 ; j++)
Question cout<<a[i][j];

Page 19
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A 1 2 3 4 5 junk
B 123455
C 123450
D Run time error
Answer C
Marks 2
Unit 2

Id 66
Question Which of the following data structures are indexed structure?
A L
Trees
B Linked list
C Linear arrays
D All of these
Answer B
Marks 1
Unit 2

Id 67
When new data is to be inserted into a data structure, but there is no available space
Question is called ________________
A Overflow
B Saturated
C Houseful
D Underflow
Answer B
Marks 1
Unit

Id 68
Question Array name is ______
A An array variable
B A common name shared by all elements
C A keyword
D Not used in a program
Answer B
Marks 1
Unit 2

Id

Page 20
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question To initialize a 5 element array all having value 1 is given by ……


A int num[ ] = (1);
B int num[ ] = {1,1,1,1,1};
C int num[ 5 ] = (1);
D int num[ 4 ] = (1,1,1,1,1);
Answer B
Marks 1
Unit 2

ID 69
Question Missing elements of partially initialized arrays are ………
A Set to zero
B Not defined
C Invalid
D Set to one
Answer C
Marks 1
Unit 2

ID 70
Question Two-way list may be maintained in memory by means of .............
A Queues
B Linear arrays
C Non linear arrays
D Stacks
Answer B
Marks 1
Unit 2

ID 71
Question Sparse matrices have?
A many zero entries
B many non- zero entries
C higher dimension
D none of above
Answer A
Marks 1
Unit 2

ID 72
Question Two dimensional arrays are also called ?

Page 21
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

A Matrix Array
B Table Array
C Both a and b
D None of the Above
Answer C
Marks 1
Unit 2

ID 73
Question Which of the following function sets first n characters of a string to a given character?
A strinit()
B strnset()
C strset()
D strcset()
Answer B
Marks 1
Unit 2

ID 74
Question If the two strings are identical, then strcmp() function returns
A -1
B 1
C 0
D 2
Answer C
Marks 1
Unit 2

ID 75
Question The library function used to find the last occurrence of a character in a string is
A strnstr()
B laststr()
C strrchr()
D strstr()
Answer C
Marks 1
Unit 2

ID 76
Which of the following function is used to find the first occurrence of a given string
Question in another string?
A strchr()

Page 22
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

B strrchr()
C strstr()
D strnset()
Answer C
Marks 1
Unit 2

ID 77
Which of the following function is more appropriate for reading in a multi-word
Question string?
A printf();
B scanf();
C gets();
D puts();
Answer C
Marks 1
Unit 2

ID 78
Question Which of the following function is correct that finds the length of a string?
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
{ length++; s++; }
return (length);
}
A
int xstrlen(char s)
{
int length=0;
while(*s!='\0')
length++; s++;
return (length);
}
B
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
length++;
return (length);
}
C
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
s++;
return (length);
}
D
Answer A
Marks 4
Unit 2

ID 79

Page 23
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

Question An array elements are always stored in ________ memory locations.


A Sequential
B Random
C Sequential and Random
D None of the above
Answer A
Marks 1
Unit 2

ID 80
Question
A
B
C
D
Answer
Marks
Unit 2

ID 81
What will be printed after execution of the following code?
void main()
{
int arr[10] = {1,2,3,4,5};
printf("%d", arr[5]);
Question }
A Garbage Value
B 5
C 6
D 0
Answer D
Marks 1
Unit 2

ID 82
Question What is right way to Initialize array?
A int num[6] = { 21, 41, 2, 15, 4, 5 };
B int n{} = { 21, 41, 2, 15, 4, 5 };
C int n{6} = { 21, 41, 2 };
D int n(6) = { 21, 41, 2, 15, 4, 5 };
Answer A
Marks 1
Unit 2

Page 24
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

ID 83
What will be the output of the following code?\
#include"stdio.h"
void main()
{
int a[10];
printf("%d %d", a[-1], a[12]);
Question }
A 00
B Garbage value 0
C 0 Garbage Value
D Garbage value Garbage Value
Answer D
Marks 2
Unit 2

ID 84
Let x be an array. Which of the following operations are illegal?
1. ++X
2. X+1
3. X++
Question 4. X*2
A I and II
B I, II and III
C II and III
D I, III and IV
Answer D
Marks 2
Unit 2

ID 85
Question What is the maximum number of dimensions an array in C may have?
A 2
B 8
C 20
D Theoretically no limit. The only practical limits are memory size and compilers
Answer D
Marks 1
Unit 2

ID 86
What will be the output of the program?
#include"stdio.h"
int main()
Question {

Page 25
Data Structures & Algorithms , M.C.Q. BANK, FOR UNIT -2 , SECOND YEAR COMP. ENGG. SEM-1, 2016 PATTERN ,
U.O.P.

int arr[5] = {10};


printf("%d", 0[arr]);

return 0;
}
A 1
B 0
C 10
D 6
Answer C
Marks 2
Unit 2

ID
Question
A
B
C
D
Answer
Marks
Unit

ID
Question
A
B
C
D
Answer
Marks
Unit

ID
Question
A
B
C
D
Answer
Marks
Unit

Page 26

You might also like