DSP MFT
DSP MFT
1.
What is the time complexity of binary search in the worst case?
a) O(n)
b) O(n log n)
c) O(log n)
d) O(1)
2.
Which of the following is not a type of data structure?
a) Array
b) Linked List
c) Class
d) Stack
3.
What does malloc() function return if memory allocation fails?
a) NULL
b) Garbage value
c) 0
d) -1
4.
Which notation is used to represent the best-case complexity of an algorithm?
a) Big-O
b) Theta (Θ)
c) Omega (Ω)
d) Sigma (Σ)
5.
What is the space complexity of an adjacency matrix?
a) O(n)
b) O(n²)
c) O(n log n)
d) O(1)
6.
In asymptotic notations, what does O(1) represent?
a) Constant time complexity
b) Linear time complexity
c) Constant space complexity
d) None of the above
7.
What is the time complexity for accessing an element in an array?
a) O(n)
b) O(log n)
c) O(1)
d) O(n²)
8.
What is the purpose of calloc() in C?
a) To allocate memory and initialize it to zero
b) To allocate memory without initialization
c) To clear memory
d) None of the above
9.
In dynamic arrays, which function increases the array size?
a) realloc()
b) calloc()
c) malloc()
d) free()
10.
Which notation represents the worst-case time complexity?
a) Big-O
b) Omega (Ω)
c) Theta (Θ)
d) Sigma (Σ)
11.
What is the key advantage of using pointers in C?
a) Accessing memory directly
b) Handling arrays dynamically
c) Both a and b
d) None of the above
12.
Which of these is an abstract data type?
a) Stack
b) Queue
c) Linked List
d) All of the above
13.
Which dynamic memory allocation function is used to resize allocated memory?
a) realloc()
b) calloc()
c) malloc()
d) free()
14.
What does the "sizeof" operator in C return?
a) The size of a pointer
b) The size of the data type in bytes
c) The memory space occupied by an object in bytes
d) None of the above
15.
Which data structure supports Last-In-First-Out (LIFO) operations?
a) Queue
b) Stack
c) Array
d) Binary Tree
Unit 2: Stack, Queue, and Linked List
16.
Which operation is not performed by a stack?
a) Push
b) Pop
c) Enqueue
d) Peek
17.
What is the time complexity of the push operation in a stack implemented using an array?
a) O(n)
b) O(1)
c) O(log n)
d) O(n²)
18.
What is the primary difference between a queue and a stack?
a) Queue is FIFO, Stack is LIFO
b) Queue is LIFO, Stack is FIFO
c) Queue is for sorting, Stack is for searching
d) Queue and Stack are the same
19.
Which of the following is true about a circular queue?
a) It can cause overflow even if the queue has space.
b) It uses dynamic arrays.
c) It doesn’t need front and rear pointers.
d) It cannot store more than 5 elements.
20.
In a singly linked list, which part contains the address of the next node?
a) Data
b) Head
c) Pointer
d) Tail
21.
In a queue, elements are inserted at the:
a) Front
b) Rear
c) Middle
d) None of the above
22.
Which of the following data structures is best for implementing recursion?
a) Queue
b) Stack
c) Array
d) Linked List
23.
What is the condition for a queue to be empty?
a) front == rear
b) front == -1
c) front > rear
d) rear == maxSize
24.
Which type of linked list allows traversal in both directions?
a) Singly linked list
b) Doubly linked list
c) Circular linked list
d) Static linked list
25.
What does "NULL" represent in a linked list?
a) Starting node
b) End of the list
c) Middle of the list
d) None of the above
Unit 3: Trees
26.
What is the height of a binary tree with a single node?
a) 0
b) 1
c) -1
d) Depends on the tree type
27.
Which tree traversal method is in the order: Left, Root, Right?
a) Preorder
b) Inorder
c) Postorder
d) Level-order
28.
What is a full binary tree?
a) A tree where each node has 2 children.
b) A tree where every node has either 0 or 2 children.
c) A tree with only one child per node.
d) A tree with all leaves at the same level.
29.
What is the time complexity for searching in a balanced binary search tree?
a) O(log n)
b) O(n)
c) O(1)
d) O(n log n)
30.
Which of the following is an application of trees?
a) Sorting
b) Expression evaluation
c) Routing algorithms
d) All of the above
Unit 3: Trees (Continued)
31.
In a binary tree, the number of leaf nodes is always one more than:
a) The number of root nodes
b) The number of nodes with two children
c) The number of internal nodes
d) None of the above
32.
What is a perfect binary tree?
a) A tree where each node has at least one child
b) A tree where all levels are completely filled
c) A tree where all internal nodes have two children and all leaves are at the same level
d) None of the above
33.
In a threaded binary tree, NULL pointers are replaced by:
a) Pointers to the inorder predecessor or successor
b) Pointers to the root node
c) Pointers to the leftmost node
d) None of the above
34.
Which traversal is used to convert a binary tree into a mirror image?
a) Preorder traversal
b) Postorder traversal
c) Inorder traversal
d) Level-order traversal
35.
What is the maximum number of nodes in a binary tree of height h?
a) 2^h
b) 2^h - 1
c) 2^(h+1) - 1
d) None of the above
36.
Which data structure is used to implement DFS on a graph or tree?
a) Stack
b) Queue
c) Priority Queue
d) Linked List
37.
How many children can a binary tree node have?
a) 0, 1, or 2
b) Only 2
c) Only 1
d) Any number
38.
Which of the following is true for a binary search tree?
a) Left child has a greater value than the parent.
b) Left child has a smaller value than the parent.
c) Both children have greater values than the parent.
d) None of the above
39.
What is the property of a min-heap?
a) Parent node is smaller than its children.
b) Parent node is larger than its children.
c) All levels are fully filled except the last.
d) None of the above
40.
Which of the following is an example of a non-linear data structure?
a) Graph
b) Array
c) Stack
d) Queue
42.
What is the worst-case time complexity of Merge Sort?
a) O(n log n)
b) O(n²)
c) O(n)
d) O(log n)
43.
Which of these searching algorithms requires the array to be sorted?
a) Linear Search
b) Binary Search
c) Interpolation Search
d) Both b and c
44.
Heap Sort is based on which data structure?
a) Binary Tree
b) Binary Heap
c) Graph
d) Linked List
45.
What is the best-case time complexity of Insertion Sort?
a) O(n log n)
b) O(n)
c) O(n²)
d) O(1)
46.
Which sorting algorithm divides the array into partitions?
a) Quick Sort
b) Merge Sort
c) Bubble Sort
d) Insertion Sort
47.
Which algorithm is best suited for nearly sorted data?
a) Quick Sort
b) Merge Sort
c) Insertion Sort
d) Heap Sort
48.
What is the time complexity of Bubble Sort in the worst case?
a) O(n log n)
b) O(n²)
c) O(n)
d) O(log n)
49.
Which sorting algorithm uses the divide-and-conquer technique?
a) Bubble Sort
b) Insertion Sort
c) Merge Sort
d) None of the above
50.
Which algorithm is the most efficient for large datasets?
a) Bubble Sort
b) Selection Sort
c) Merge Sort
d) Linear Search
51.
What is the best case for sequential search?
a) Element found at the first position
b) Element not found
c) Element found at the last position
d) Element found in the middle
52.
Binary Search works efficiently on:
a) Sorted arrays
b) Unsorted arrays
c) Linked lists
d) Graphs
53.
What is the time complexity of Quick Sort in the worst case?
a) O(n log n)
b) O(n²)
c) O(n)
d) O(log n)
54.
In Radix Sort, the complexity depends on:
a) Number of elements
b) Number of digits in the largest number
c) Both a and b
d) None of the above
55.
Which sorting algorithm is stable?
a) Quick Sort
b) Heap Sort
c) Merge Sort
d) None of the above
General Questions (Mixed Topics)
56.
Which operation is the most expensive in an array?
a) Traversal
b) Access
c) Insertion/Deletion
d) None of the above
57.
What is a sparse matrix?
a) A matrix with most elements as zero
b) A matrix with most elements as one
c) A matrix with only one row
d) None of the above
58.
What is Dijkstra’s algorithm used for?
a) Finding the shortest path in a graph
b) Sorting a list
c) Balancing a tree
d) None of the above
59.
Hashing is used for:
a) Sorting
b) Searching
c) Traversal
d) None of the above
60.
What is the worst-case time complexity of hashing?
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
General Questions (Mixed Topics) Continued
61.
Which of the following is an application of graphs?
a) Shortest path algorithms
b) Sorting numbers
c) Evaluating expressions
d) None of the above
62.
What does a hash function do?
a) Converts data into binary
b) Maps keys to specific indices in a hash table
c) Sorts data in ascending order
d) Searches for data in constant time
63.
Warshall’s algorithm is used for:
a) Finding the shortest path in a graph
b) Finding the transitive closure of a graph
c) Topological sorting
d) Detecting cycles in a graph
64.
In a hash table, what is a collision?
a) When two keys map to the same index
b) When a key maps to a null value
c) When a key cannot be found
d) None of the above
65.
Which data structure is ideal for implementing Dijkstra’s algorithm?
a) Priority Queue
b) Stack
c) Array
d) Hash Table
66.
What is the time complexity of Breadth-First Search (BFS)?
a) O(V + E)
b) O(V²)
c) O(E log V)
d) O(V log E)
67.
Which data structure is used in Depth-First Search (DFS)?
a) Queue
b) Stack
c) Linked List
d) Hash Table
68.
What is the function of calloc()?
a) Allocates memory without initialization
b) Allocates memory and initializes it to zero
c) Frees memory
d) None of the above
69.
What is the advantage of linked representation of graphs over adjacency matrix?
a) Easier implementation
b) Space-efficient for sparse graphs
c) Faster for all operations
d) None of the above
70.
In a binary search tree, what is the time complexity of finding the maximum element?
a) O(h)
b) O(log n)
c) O(1)
d) O(n)
72.
Which sorting algorithm has the best worst-case performance?
a) Quick Sort
b) Merge Sort
c) Selection Sort
d) Insertion Sort
73.
What is the time complexity of linear search?
a) O(n)
b) O(n²)
c) O(log n)
d) O(1)
74.
Which data structure is used for implementing recursion?
a) Queue
b) Array
c) Stack
d) Linked List
75.
What is the main advantage of linked lists over arrays?
a) Dynamic size allocation
b) Faster traversal
c) Easier sorting
d) Random access
76.
In Dijkstra’s algorithm, what does the priority queue store?
a) Nodes and their parent nodes
b) Nodes and their current shortest distance
c) Edges and weights
d) Graph traversal sequence
77.
What is the best data structure for priority queues?
a) Stack
b) Queue
c) Heap
d) Linked List
78.
Which tree traversal method is used in expression trees for postfix evaluation?
a) Inorder traversal
b) Preorder traversal
c) Postorder traversal
d) Level-order traversal
79.
What is the space complexity of Depth-First Search (DFS)?
a) O(V)
b) O(E)
c) O(V + E)
d) O(log V)
80.
Which algorithm uses divide-and-conquer for sorting?
a) Bubble Sort
b) Merge Sort
c) Insertion Sort
d) Selection Sort