[go: up one dir, main page]

0% found this document useful (0 votes)
10 views8 pages

Dsa MCQS

The document consists of multiple-choice questions related to data structures and algorithms, covering topics such as stack and queue applications, sorting algorithms, linked lists, graph representations, hash tables, binary search trees, and various expressions. Each question presents a set of options for the reader to select the correct answer. The questions assess knowledge on data structure implementations, complexities, and properties.

Uploaded by

Uzair Zaid
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)
10 views8 pages

Dsa MCQS

The document consists of multiple-choice questions related to data structures and algorithms, covering topics such as stack and queue applications, sorting algorithms, linked lists, graph representations, hash tables, binary search trees, and various expressions. Each question presents a set of options for the reader to select the correct answer. The questions assess knowledge on data structure implementations, complexities, and properties.

Uploaded by

Uzair Zaid
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/ 8

1. Which one of the following is an application of Stack Data Structure?

a) Managing function calls


b) The stock span problem
c) Arithmetic expression evaluation
d) All of the above

2. Which one of the following is an application of Queue Data Structure?


a) When a resource is shared among multiple consumers.
b) When data is transferred asynchronously (data not necessarily received
at same rate as sent) between two processes
c) Load Balancing
d) All of the above

3. Which of the following sorting algorithms can be used to sort a random


linked list with minimum time complexity?
a) Insertion Sort
b) Quick Sort
c) Heap Sort
d) Merge Sort
4. Which of the following is true about linked list implementation of
stack?
a) In push operation, if new nodes are inserted at the beginning of linked
list, then in pop operation, nodes must be removed from end.
b) In push operation, if new nodes are inserted at the end, then in pop
operation, nodes must be removed from the beginning.
c) Both of the above
d) None of the above

5. Which of the following is an advantage of adjacency list representation


over adjacency matrix representation of a graph?
a) In adjacency list representation, space is saved for sparse graphs.
b) DFS and BSF can be done in O(V + E) time for adjacency list
representation. These operations take O(V^2) time in adjacency matrix
representation. Here is V and E are number of vertices and edges
respectively.
c) Adding a vertex in adjacency list representation is easier than
adjacency matrix representation.
d) All of the above
6. Suppose a circular queue of capacity (n – 1) elements is implemented
with an array of n elements. Assume that the insertion and deletion
operation are carried out using REAR and FRONT as array index variables,
respectively. Initially, REAR = FRONT = 0. The conditions to detect queue
full and queue empty are
a) Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT
b) Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR
c) Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT
d) Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT

7. A hash table of length 10 uses open addressing with hash function


h(k)=k mod 10, and linear probing. After inserting 6 values into an empty
hash table, the table is as shown below.

Which one of the following choices gives a possible order in which the key
values could have been inserted in the table?
a) 46, 42, 34, 52, 23, 33
b) 34, 42, 23, 52, 33, 46
c) 46, 34, 42, 23, 52, 33
d) 42, 46, 33, 23, 34, 52
8. 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 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

9. Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order


into an initially empty binary search tree. The binary search tree uses the
usual ordering on natural numbers. What is the in-order traversal
sequence of the resultant tree?
a) 7 5 1 0 3 2 4 6 8 9
b) 0 2 4 3 1 6 5 9 8 7
c) 0 1 2 3 4 5 6 7 8 9
d) 9 8 6 4 2 3 0 1 5 7

10. How can we describe an array in the best possible way?


a) The Array shows a hierarchical structure.
b) Arrays are immutable.
c) Container that stores the elements of similar types
d) The Array is not a data structure
11. Which data structure is mainly used for implementing the recursive
algorithm?
a) Queue
b) Stack
c) Binary tree
d) Linked list

12. Which of the following highly uses the concept of an array?


a) Binary Search tree
b) Caching
c) Spatial locality
d) Scheduling of Processes
Explanation:
Here, spatial locality means that the instruction accessed recently, then
the nearby memory location would be accessed in the next iteration. As
we know that in an array, all the elements are stored in a contiguous
block of memory, so spatial locality is accessed quickly.

13. What is the output of the below code?


#include <stdio.h>
int main()
{
int arr[5]={10,20,30,40,50};
printf("%d", arr[5]);
return 0;
}
a) Garbage value
b) 10
c) 50
d) None of the above

14. Which of the following is the infix expression?


a) A+B*C
b) +A*BC
c) ABC+*
d) None of the above

15. Which of the following is the prefix form of A+B*C?


a) A+(BC*)
b) +AB*C
c) ABC+*
d) +A*BC

16. What is the outcome of the prefix expression + - * 3 2 / 8 4 1?


a) 12
b) 11
c) 5
d) 4
Explanation:
Reverse of the prefix expression: 1 4 8 / 2 3 * - +
The infix expression of the above prefix expression is:
(2*3) - (8/4) +1
6 -2 +1 = 5

17. What is another name for the circular queue among the following
options?
a) Square buffer
b) Rectangle buffer
c) Ring buffer
d) None of the above

18. The time complexity of enqueue operation in Queue is __


a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)

19. Which of the following that determines the need for the Circular
Queue?
a) Avoid wastage of memory
b) Access the Queue using priority
c) Follows the FIFO principle
d) None of the above
20. The tango tree is a type of:
a) Binary Search Tree
b) K-ary Tree
c) Ternary Tree
d) AVL Tree

21. A splay operation refers to:


a) the removal of leaf node
b) the movement of root to leaf
c) the movement of a node to root
d) the movement of parent node to a child node’s down

You might also like