Data-Structure-And-Algorithms (Set 2)
Data-Structure-And-Algorithms (Set 2)
2 of 4 sets
101. A sort which compares adjacent elements in a list and switches wherever
necessary is _______
A. insertion sort
B. bubble sort
C. selection sort
D. none of these
Answer:B
104. In bubble sort,for a file of size n,after p iterations number of records in proper
position is____
A. n-p
B. n-p+1
C. n-p+2
D. p
Answer:A
105. In bubble sort,for a file of size n,during each pth pass the number of last
records left out are____
A. n-p
B. n-p+1
C. p
D. p-1
Answer:D
106. Given a file size n the number of times a given file is passed through in bubble
sort is____
A. n2
B. n-1
C. nlogn
D. logn
Answer:A
108. 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. bubble sort
D. merge sort
Answer:B
110. In selection sort of n elements,how many times is the swp function called in the
complete execution of the algorithm?
A. 1
B. n-1
C. n(n-1)/2
D. none of these
Answer:B
113. Following function is used to find the first occurrence of given string in
another string
A. strchar
B. strnset
C. strstr
D. strrchr
Answer:D
114. Which of the following is more appropriate for reading a multi_word string?
A. printf
B. scanf
C. put
116. What will be the output of the following code? Int main(){char str[9]="My
Computer";printf("%s\n",str);return 0;}
A. mycompute
B. syntax error
C. runtime error
D. none of these
Answer:B
118. ____operator is used to get the value stored at address stored in pointer
variable
A. *
B. &
C. dot
D. +
Answer:A
121. 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);}
A. 10 10 garbage
B. 10 garbage garbage
C. 10 10 10
D. syntax error
Answer:C
127. How many bits are absolutely necessary to store an ASCII character ?
A. 7
B. 8
C. 15
D. 16
Answer:A
136. 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;
}
A. 320
B. 1
C. 64
D. none of the above
Answer:C
137. 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;
}
A. 343
B. 27
C. 133
D. compiler error
Answer:B
139. 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;
}
A. equal
B. less than
C. greater than
D. compiler error
Answer:B
140. 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;
}
A. 21
B. 18
C. 12
141. 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;
}
A. it will print nothing
B. -3
C. -2
D. compiler error
Answer:D
142. 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;
}
A. 12 11 11
B. 12 10 10
C. 11 11 12
D. 10 10 12
Answer:A
143. 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;
}
144. 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;
}
A. cquestionbank
B. cquestionbank\\0
C. (null)
D. it will print nothing
Answer:C
146. 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;
147. 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;
}
A. 2
B. 4
C. 8
D. 10
Answer:C
148. 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;
}
A. 8
B. \8\
C. 9
D. compiler error
Answer:D
149. 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;
}
A. 35
150. 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;
}
A. 25
B. 26
C. any adress
D. garbage value
Answer:D
152. 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;
}
153. 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;
}
A. equal
B. less than
C. greater than
D. compiler error
Answer:D
154. 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;
}
A. 5
B. 6
C. 7
D. 0
Answer:D
157. The data type created by the data abstraction process is called
A. class
B. structure
C. abstract data type
D. user defined data type
Answer:C
158. A variable which is visible only in the function in which it is defined, is called
A. static
B. auto
C. external
D. local
Answer:D
162. Which data structure allows deleting data elements from front and inserting
at rear?
A. stack
B. queue
C. dequeue
D. binary search tree
Answer:B
166. 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
A. f(n) x g(n)
B. max ( f(n),g(n))
C. min (f(n),g(n))
D. f(n) + g(n)
Answer:B
168. Consider that n elements are to be sorted. What is the worst case time
complexity of Bubble sort?
A. o(1)
B. o(log2n)
C. o(n)
D. o(n^2)
Answer:D
A. two
B. eight
C. twenty
D. theoratically no limit. the only practical limits are memory size and compilers
Answer:D
A. unsigned character
B. unsigned integer
C. character
D. none of\ these
Answer:B
176. Which of the following 'C' type is not a primitive data structure?
A. int
B. float
C. char
D. none of these
Answer:D
A. 263
B. ascii equivalent of 263
C. rings the bell
D. garbage
Answer:C
178. The variables which can be accessed by all modules in a program, are called
183. What additional requirement is placed on an array, so that binary search may
be used to locate an entry?
A. the array elements must form a heap
B. the array must have at least 2 entries.
C. the array must be sorted.
D. the array\s size must be a power of two.
Answer:C
185. 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?
A. abcd
B. abdc
C. dcab
D. dcba
Answer:D
186. Which of the following formulas in big-O notation best represent the
expression n²+35n+6?
A. o(n³)
B. o(n²)
C. o(n)
188. The keyword used to transfer control from a function back to the calling
function is
A. switch
B. goto
C. go back
D. return
Answer:D
189. How many times the program will print "Amrutvahini" ? #include<stdio.h>
int main()
{
printf("Amrutvahini");
main();
return 0;
}
A. infinite times
B. 32767 times
C. 65535 times
D. till stack overflows
Answer:D
int main()
{
while(i)
191. In a linked list, the pointer of the last node contains a special value, called the
______ pointer.
A. null
B. zero
C. link
D. next pointer
Answer:A
192. In a ________ linked list, the last node's link field points to the first node of
the list.
A. circularly
B. linearly
C. sequentially
D. indexed
Answer:A
193. The second part of the node, is called _______ field, and contains the address
of the next node in the list.
A. pointer
B. field
C. node
194. The link list also contains a list pointer variable called start or ________.
A. name
B. field
C. node
D. link
Answer:A
195. A ________ linked list is a linked list structure in which each node has a
pointer to both its successor and predecessor.
A. circularly
B. doubly
C. linear
D. sequential
Answer:B
196. _______ list is a special list that is maintained, which consists of unused
memory cells.
A. linear
B. doubly linked
C. circularly linked
D. free storage
Answer:D
197. _______ is a technique using which a computer periodically collects all the
deleted space onto the free storage list.
A. garbage collection
B. garbage compaction
C. linked list
D. free storage
Answer:A
198. _______ attacks the problem of fragmentation by moving all the allocated
blocks to one end of memory, thus combining all the holes.
199. A ________ linked list is a linked list which always contains a special node,
called the header node.
A. circular
B. grounded
C. header
D. doubly
Answer:C