Quiznetik

Data Structure and Algorithms (DSA) | Set 2

1. A sort which compares adjacent elements in a list and switches wherever necessary is _______

Correct : B. bubble sort

2. Which of the following sorting method is the slowest?

Correct : C. bubble sort

3. Consider that n elements are to be sorted.The worst case complexity of bubble sort is____

Correct : D. o(n2)

4. In bubble sort,for a file of size n,after p iterations number of records in proper position is____

Correct : A. n-p

5. In bubble sort,for a file of size n,during each pth pass the number of last records left out are____

Correct : D. p-1

6. Given a file size n the number of times a given file is passed through in bubble sort is____

Correct : A. n2

7. Total number of comparision in bubble sort is____

Correct : B. o(n2)

8. 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

Correct : B. selection sort

9. The selection sort is basically a method of repeated

Correct : C. position adjustment

10. In selection sort of n elements,how many times is the swp function called in the complete execution of the algorithm?

Correct : B. n-1

11. If two string are identical then strcmp() function returns____

Correct : C. 0

12. How will you print\n on screen?

Correct : D. printf("\\\\n");

13. Following function is used to find the first occurrence of given string in another string

Correct : D. strrchr

14. Which of the following is more appropriate for reading a multi_word string?

Correct : D. gets

15. What will be the output of the following code? Int main(){printf("Hello","Word\n");return 0;}

Correct : A. hello

16. What will be the output of the following code? Int main(){char str[9]="My Computer";printf("%s\n",str);return 0;}

Correct : B. syntax error

17. Pointer is a___________

Correct : C. a variable that stores the address of some other variable

18. ____operator is used to get the value stored at address stored in pointer variable

Correct : A. *

19. Which of the following statement is true about char ****a ?

Correct : B. a is pointer to a pointer to a pointer to char

20. Are *ptr++ and ++*ptr are same?

Correct : A. no they are not same

21. What will be the output of the following code? Void main(){int a=10;int *b=&a;int **c=&b;printf("%d %d %d",a,*b,**c);}

Correct : C. 10 10 10

22. Which of the following is a collection of different data type elements?

Correct : B. structure

23. What is the similarity between structure,union and enum?

Correct : D. all of them let you define new data types

24. Which of the following can not be a structure member?

Correct : C. function

25. The members of the union are accessed by____

Correct : C. both a and b

26. a-> is systematically correct if_____

Correct : A. a is a pointer to a structure in which b is a field

27. How many bits are absolutely necessary to store an ASCII character ?

Correct : A. 7

28. The result of 0001 1010 / 0001 0101 is

Correct : A. 0001 1111

29. The result of 0001 1010 & 0000 1000 is ___

Correct : C. 0000 1000

30. The result of 0001 1010 ~ 0100 0011 is

Correct : B. 1010 0100

31. The result of 0001 1010^0001 0000 is____

Correct : C. 0000 0010

32. The result of 0001 1010 << 2 is____

Correct : B. 0110 1000

33. The result of 0001 1010 >>2 is____

Correct : C. 0000 0110

34. The most significant bit is lost in following operation

Correct : A. <<

35. The result of i)true AND false II)false or false

Correct : D. i)is false and ii)is false

36. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ int i=320; char *ptr=(char *)&i; printf("%d",*ptr); return 0; }

Correct : C. 64

37. What will be output if you will compile and execute the following c code? #include<stdio.h> #define x 5+2 int main(){ int i; i=x*x*x; printf("%d",i); return 0; }

Correct : B. 27

38. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ char c=125; c=c+10; printf("%d",c); return 0; }

Correct : C. -121

39. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ float a=5.2; if(a==5.2) printf("Equal"); else if(a<5.2) printf("Less than"); else printf("Greater than"); return 0; }

Correct : B. less than

40. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ int i=4,x; x=++i + ++i + ++i; printf("%d",x); return 0; }

Correct : A. 21

41. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ int a=2; if(a==2){ a=~a+2<<1; printf("%d",a); } else{ break; } return 0; }

Correct : D. compiler error

42. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ int a=10; printf("%d %d %d",a,a++,++a); return 0; }

Correct : A. 12 11 11

43. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ char *str="Hello world"; printf("%d",printf("%s",str)); return 0; }

Correct : D. hello world13

44. What will be output if you will compile and execute the following c code? #include <stdio.h> #include <string.h> int main(){ char *str=NULL; strcpy(str,"cquestionbank"); printf("%s",str); return 0; }

Correct : C. (null)

45. #include <stdio.h> #include <string.h> int main(){ int i=0; for(;i<=2;) printf(" %d",++i); return 0; }

Correct : C. 1 2 3

46. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ int x; for(x=1;x<=5;x++); printf("%d",x); return 0; }

Correct : C. 6

47. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ printf("%d",sizeof(5.2)); return 0; }

Correct : C. 8

48. What will be output if you will compile and execute the following c code? #include <stdio.h> #include <string.h> int main(){ char c='\08'; printf("%d",c); return 0; }

Correct : D. compiler error

49. What will be output if you will compile and execute the following c code? #include<stdio.h> #define call(x,y) x##y int main(){ int x=5,y=10,xy=20; printf("%d",xy+call(x,y)); return 0; }

Correct : D. 40

50. What will be output if you will compile and execute the following c code? #include<stdio.h> int * call(); int main(){ int *ptr; ptr=call(); printf("%d",*ptr); return 0; } int * call(){ int a=25; a++; return &a; }

Correct : D. garbage value

51. What is error in following declaration? struct outer{ int a; struct inner{ char c; }; };

Correct : C. inner structure must have name

52. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ int array[]={10,20,30,40}; printf("%d",-2[array]); return 0; }

Correct : B. -30

53. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ int i=10; static int x=i; if(x==i) printf("Equal"); else if(x>i) printf("Greater than"); else printf("Less than"); return 0; }

Correct : D. compiler error

54. What will be output if you will compile and execute the following c code? #include<stdio.h> #define max 5; int main(){ int i=0; i=max++; printf("%d",i++); return 0; }

Correct : D. 0

55. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){ double far* p,q; printf("%d",sizeof(p)+sizeof q); return 0; }

Correct : A. 12

56. C language was invented by

Correct : D. dennis ritchie

57. The data type created by the data abstraction process is called

Correct : C. abstract data type

58. A variable which is visible only in the function in which it is defined, is called

Correct : D. local

59. Unsigned integers occupies

Correct : C. one bytes

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

Correct : D. all of the above

61. In C, if you pass an array as an argument to a function, what actually gets passed?

Correct : C. base address of the array

62. Which data structure allows deleting data elements from front and inserting at rear?

Correct : B. queue

63. Queue is a -------------- List .

Correct : A. fifo

64. Stack is a -------------List.

Correct : A. lifo

65. A node in a linked list must contain at least

Correct : B. two fields

66. An algorithm is made up of two independent time complexities f (n) and g (n). Then the complexities of the algorithm is in the order of

Correct : B. max ( f(n),g(n))

67. Big O notation is defined for

Correct : A. time and space complexity

68. Consider that n elements are to be sorted. What is the worst case time complexity of Bubble sort?

Correct : D. o(n^2)

69. The complexity of Binary search algorithm is

Correct : B. o(log n)

70. The complexity of linear search algorithm is

Correct : A. o(n)

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

Correct : C. arrays

72. What is the maximun number of dimensions an array in C may have?

Correct : D. theoratically no limit. the only practical limits are memory size and compilers

73. An external variable

Correct : D. all of these

74. The declaration "unsigned u" indicates u is a/an

Correct : B. unsigned integer

75. A declaration "short int" is used for variables

Correct : C. which may require less storage than normal integers

76. Which of the following 'C' type is not a primitive data structure?

Correct : D. none of these

77. The program fragment int i = 263 ; putchar (i) ; prints

Correct : C. rings the bell

78. The variables which can be accessed by all modules in a program, are called

Correct : D. global variables

79. The main measures of efficiency of an algorithm are

Correct : C. time and space

80. The worst case occures in linear search algorithms when

Correct : D. item is last element in the array or is not there at all.

81. the terms push and pop are related to

Correct : A. stack

82. What will be the output of the program? #include<stdio.h> int main() { int X=40; { int X=20; printf("%d ", X); } printf("%d\n", X); return 0; }

Correct : D. error

83. What additional requirement is placed on an array, so that binary search may be used to locate an entry?

Correct : C. the array must be sorted.

84. One difference between a queue and a stack is:

Correct : C. queues use two ends of the structure; stacks use only one.

85. If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed?

Correct : D. dcba

86. Which of the following formulas in big-O notation best represent the expression n²+35n+6?

Correct : B. o(n²)

87. What term is used to describe an O(n) algorithm

Correct : B. linear

88. The keyword used to transfer control from a function back to the calling function is

Correct : D. return

89. How many times the program will print "Amrutvahini" ? #include<stdio.h> int main() { printf("Amrutvahini"); main(); return 0; }

Correct : D. till stack overflows

90. What will be the output of the program? #include<stdio.h> int i; int fun(); int main() { while(i) { fun(); main(); } printf("Hello\n"); return 0; } int fun() { printf("Hi"); }

Correct : A. hello

91. In a linked list, the pointer of the last node contains a special value, called the ______ pointer.

Correct : A. null

92. In a ________ linked list, the last node's link field points to the first node of the list.

Correct : A. circularly

93. The second part of the node, is called _______ field, and contains the address of the next node in the list.

Correct : D. link

94. The link list also contains a list pointer variable called start or ________.

Correct : A. name

95. A ________ linked list is a linked list structure in which each node has a pointer to both its successor and predecessor.

Correct : B. doubly

96. _______ list is a special list that is maintained, which consists of unused memory cells.

Correct : D. free storage

97. _______ is a technique using which a computer periodically collects all the deleted space onto the free storage list.

Correct : A. garbage collection

98. _______ attacks the problem of fragmentation by moving all the allocated blocks to one end of memory, thus combining all the holes.

Correct : B. overflow

99. A ________ linked list is a linked list which always contains a special node, called the header node.

Correct : C. header

100. A polynomial can be represented in a _______ by just storing the coefficient and exponent of each term.

Correct : B. linked list