273
94.3k

340+ Data Structure and Algorithms (DSA) Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Computer Science Engineering (CSE) , Information Technology Engineering (IT) , Electronics and Communication Engineering , Common Topics in Competitive and Entrance exams .

151.

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

A. nesting of structure is not allowed in c
B. it is necessary to initialize the member variable
C. inner structure must have name
D. outer structure must have name
Answer» C. inner structure must have name
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;
}

A. -60
B. -30
C. 60
D. garbage value
Answer» B. -30
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. compiler error
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. 0
155.

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; }

A. 12
B. 8
C. 4
D. 1
Answer» A. 12
156.

C language was invented by

A. abacus
B. charles babage
C. thomson
D. dennis ritchie
Answer» D. dennis ritchie
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. abstract data type
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. local
159.

Unsigned integers occupies

A. two bytes
B. four bytes
C. one bytes
D. eight bytes
Answer» C. one bytes
160.

Which of the following data structure is linear type ?

A. strings
B. lists
C. queues
D. all of the above
Answer» D. all of the above
161.

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. base address of the array
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. queue
163.

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

A. fifo
B. lifo
C. lilo
D. liso
Answer» A. fifo
164.

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

A. lifo
B. fifo
C. lilo
D. lito
Answer» A. lifo
165.

A node in a linked list must contain at least

A. three fields
B. two fields
C. four fields
D. one field
Answer» B. two fields
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. max ( f(n),g(n))
167.

Big O notation is defined for

A. time and space complexity
B. optimality
C. seaching
D. none of the above
Answer» A. time and space complexity
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. o(n^2)
169.

The complexity of Binary search algorithm is

A. o(n)
B. o(log n)
C. o(n2)
D. o(n log n)
Answer» B. o(log n)
170.

The complexity of linear search algorithm is

A. o(n)
B. o(log n)
C. o(n2)
D. o(n log n)
Answer» A. o(n)
171.

Which of the following data structure is linear data structure?

A. trees
B. graphs
C. arrays
D. none of above
Answer» C. arrays
172.

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


A. two
B. eight
C. twenty
D. theoratically no limit. the only practical limits are memory size and compilers
Answer» D. theoratically no limit. the only practical limits are memory size and compilers
173.

An external variable

A. is globally accessible by all functions
B. has a declaration
C. will be initialized to 0 if not initialized
D. all of these
Answer» D. all of these
174.

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

A. unsigned character
B. unsigned integer
C. character
D. none of\ these
Answer» B. unsigned integer
175.

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 integers
D. all of these
Answer» C. which may require less storage than normal integers
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. none of these
177.

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

A. 263
B. ascii equivalent of 263
C. rings the bell
D. garbage
Answer» C. rings the bell
178.

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


A. local variables
B. internal variables
C. external variable
D. global variables
Answer» D. global variables
179.

The main measures of efficiency of an algorithm are

A. processor and memory
B. complexity and capacity
C. time and space
D. data and space
Answer» C. time and space
180.

The worst case occures in linear search algorithms when

A. item is somewhere in the middle of the array
B. item is not there in the array at all
C. item is last element in the array
D. item is last element in the array or is not there at all.
Answer» D. item is last element in the array or is not there at all.
181.

the terms push and pop are related to

A. stack
B. queue
C. array
D. none of the above
Answer» A. stack
182.

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;
}

A. 40 40
B. 20 20
C. 20
D. error
Answer» D. error
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. the array must be sorted.
184.

One difference between a queue and a stack is:

A. queues require dynamic memory, but stacks do not.
B. stacks require dynamic memory, but queues do not
C. queues use two ends of the structure; stacks use only one.
D. stacks use two ends of the structure, queues use only one.
Answer» C. queues use two ends of the structure; stacks use only one.
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. dcba
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)
D. o(42)
Answer» B. o(n²)
187.

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

A. constant
B. linear
C. logarithmic
D. quadratic
Answer» B. linear
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. return
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. till stack overflows
190.

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");
}

A. hello
B. hi hello
C. no output
D. infinite loop
Answer» A. hello
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. null
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. circularly
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
D. link
Answer» D. link
194.

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

A. name
B. field
C. node
D. link
Answer» A. name
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. doubly
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. free storage
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. garbage collection
198.

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

A. underflow
B. overflow
C. compaction
D. free storage
Answer» B. overflow
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. header
200.

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

A. array
B. linked list
C. queue
D. stack
Answer» B. linked list

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.