These Data Structures and Algorithms multiple-choice questions and their answers will help you strengthen your grip on the subject of Data Structures and Algorithms. You can prepare for an upcoming exam or job interview with these Data Structures and Algorithms MCQs.
So scroll down and start answering.
A. sorting data that is too large to fit into RAM
B. sorting data without the usage of a recursive implementation
C. sorting data outside a specific performance bound
A. Insertion sort
B. Selection sort
C. Quicksort
D. Bubble sort
A. Hashing
B. Sequential Search
C. Fibonacci Search
D. Binary Search
A. Stack
B. Linked List
C. Sequence
D. Array
A. Queue
B. Array
C. Stack
D. Linked List
A. Priority Queue
B. Linked List
C. Tree
D. Array
A. Lower bound
B. Upper bound
C. Midpoint
D. Range
A. Induction
B. Recursion
C. Sequencing
D. Looping
A. Yes
B. No
A. Tree
B. Array
C. Linked List
D. Priority Queue
A. One.
B. Two. One queue is used for actual storing of data and another for storing priorities.
C. Three.
D. Four.
A. Insertion sort
B. Selection sort
C. Bubble sort
D. Quicksort
A. Sequential Search
B. Hashing algorithm has been performed
C. Sorted Array
D. Unsorted Array
A. Stack requires recursive search technique; Queue does not.
B. Stack uses selection sort; Queue uses bubble sort.
C. Stack is LIFO; Queue is FIFO.
D. Stack is FIFO; Queue is LIFO.
A. Binary Tree
B. Array
C. Linked List
D. B-tree
A. Hashtable
B. Set
C. Stack
D. Queue
A. True
B. False
A. Sorting algorithms
B. Searching algorithms
C. computational complexity measurements
A. Stack
B. Binary tree
C. Queue
D. Array
A. n!
B. 2 ^ n
C. n * log(n)
D. n ^ 3
E. n ^ 2
A. False
B. True
A. Deletion of a leaf
B. Creation of a list
C. Insertion of a node
D. Deletion of a node
A. Pointers
B. Recursion
C. Binary Search
D. Hashing
A. maps each hash value to a different valid input
B. maps each valid input to a different hash value
C. not possible
A. Array
B. Binary Tree
C. B-tree
D. Stack
A. Heap
B. Linked List
C. Stack
D. Queue
A. True
B. False
A. Compiler design
B. Simulation
C. Website design
D. Graphics
A. Set
B. Stack
C. Sequence
D. Structure
A. O(N^2)
B. It depends on how both N and M vary.
C. O(N*M)
D. O(N+M)
A. O(log n)
B. O(n^3)
C. O(n^2)
D. O(1)
E. O(n)
A. Find the 2nd largest value in an array
B. Find the 2nd smallest value in an array
C. Find the maximum value in an array.
D. Find the median value in an array
A. O(n^2)
B. O(n * log n)
C. O(log n)
D. O(n)
E. O(1)
A. False
B. True
A. Ten
B. Once
C. Three
D. Two
A. O(1)
B. O(N^2)
C. O(log N)
D. O(N)
E. O(N * log N)
A. HashMap
B. Fibonacci heap
C. Sorted list
D. B-tree
E. Doubly-linked list
A. Set
B. Height
C. Size
D. Depth
A. Right Child - Parent - Left Child
B. Left Child - Parent - Right Child
C. Parent - Left Child - Right Child
D. Left Child - Right Child - Parent
A. O(n^2)
B. O(1)
C. O(log n)
D. O(n)
A. O(n^2)
B. O(n * log n)
C. O(n)
D. O(1)
E. O(n^2 * log n)
A. Database table
B. Algorithm
C. Database
D. Data Structure
A. Linear search
B. Tree search
C. Hashing
D. Binary search
A. O(NlogN)
B. O(N*N)
C. O(1)
D. O(logN)
E. O(N)
A. Root is leaf, or has between 2 & M children.
B. Data stored only on the leaves.
C. Data is stored only on the branches.
D. All leaf nodes are at the same level.
A. Insertion sort
B. Quick sort
C. Bubble sort
D. Merge sort
A. No, they can't
B. Yes, with a slight modification to the algorithm.
C. Yes, by multiplying each edge in the graph by -1, and finding the shortest-path.
A. Preorder predecessor
B. Inorder successor
C. Suborder successor
D. Inorder predecessor
A. Size
B. Height
C. Depth
D. Set
A. O(n^2)
B. O(n)
C. O(2n)
D. O(log n)
E. O(n * log n)
A. O(|E||V|)
B. O(|E| + |V|)
C. O(|E|*sqrt(|V|))
D. O(|E|^2|V|^2)
E. O(|V|)
A. O(|E|^2|V|)
B. O(|V|)
C. O(|E|f)
D. O(|E||V|)
E. O(|E|)
A. 2 Gigabytes
B. 512 Megabytes
C. 16 Gigabytes
D. 1024 Megabytes
E. 128 Gigabytes
A. n-1 leaf nodes
B. n non-leaf nodes
C. n-1 non-leaf nodes
D. n leaf nodes
A. Breadth-first search
B. Depth-first search
A. n edges
B. n-k edges
C. (n-k)(n-k-1)/2 edges
D. (n-k)(n-k+1)/2 edges
A. 2
B. 3
C. 4
D. 6
A. Heaps are binary search trees
B. Heaps are complete binary trees
C. Heaps are full binary trees
D. Heaps contain only integer data
A. The operating system detects the infinite recursion because of the "repeated state"
B. The program keeps running until you press Ctrl-C
C. The results are non-deterministic
D. The run-time stack overflows, halting the program
A. The depth of the tree
B. The number of divisions at each level
C. The number of nodes in the tree
D. The total number of entries in all the nodes of the tree
Here is a code for an integer variable n
while (n > 0)
{
n = n/10; // Use integer division
}
What is the worst case scenario analysis for the above loop?
A.
O(1)
B. O(log n)
C.
O(n)
D.
O(n2)
Suppose we have a circular array implementation of a queue, with ten items in the queue stored at data[2] through data[11]. The CAPACITY is 42. Where does the push member function place the new entry in the array?
A.
data[1]
B.
data[2]
C.
data[11]
D. data[12]
A. Bubble sort and selection sort
B. Heap sort and merge sort
C. Quick sort and radix sort
D. Tree sort and Median-of-3 quicksort
A. add
B. append
C. insert
D. push
A. 2d+1
B. 2d
C. 2d+1-1
D. 2d2
A. A binary search begins with the middle element in the array
B. A binary search continues halving the array either until a match is found or until there are no more elements to search
C. If the search argument is greater than the value located in the middle of the binary, the binary search continues in the lower half of the array
A. A parentheses balancing program
B. Keeping track of local variables at run time
C. Syntax analyzer for a compiler
D. All of the above
A. Something between -15 and -100
B. Something between -5 and -15
C. Something between 5 and 15
D. Something between 15 and 100
A. 0
B. 1
C. 2
D. 3
A. 3
B. 4
C. 5
A. Linked list
B. Tree
C. Stack
D. Linked list of stack
A. 2h + 1 - 1
B. 2h + 1
C. 2h
D. 2h + 1 + 1
A. 511
B. 512
C. 1024
D. There is no maximum limit
A. Simple linked list
B. Circular linked list
C. Doubly linked list
D. Both b and c
A. Two entries are identical except for their keys
B. Two entries with different data have exactly the same key
C. Two entries with different keys have exactly the same hash value
D. Two entries with exactly the same key have different hash values
A. abc-+de-fg+h-/*
B. *+a-bc/-de-+f-gh
C. a+*b-/c-d-e+fgh
D. *+a-bc-/d+e-fgh
A. all the non-zero elements lie only on the leading diagonal
B. all the non-zero elements lie above the leading diagonal
C. all the non-zero elements lie below the leading diagonal
D. None of the above
A. Multigraph
B. Non - regular graph
C. Regular graph
D. Complete graph
A. 1
B. 2
C. n (n is the argument)
D. There is no fixed maximum
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
A. O(log n)
B. O(n)
C. O(n log n)
D. O(n2)
A. T(n)=O(nm)
B. T(n)=O(m*log(m))
C. T(n)=O(n*log(m))
D. T(n)=O(m*log(n))
A. data[i+1]
B. data[i+2]
C. data[2*i + 1]
D. data[2*i + 2]
A. 2k
B. 2k+1
C. K/2
D. 2K-1
A. O(1)
B. O(log2n)
C. O(n)
D. O(n*log2n)
A. Any sibling of X is also a leaf
B. Any sibling of X contains at least 41 entries
C. The parent of X has exactly 42 entries
D. X has at least 41 siblings
A. about log(n)
B. about 2*log(n)
C. about 3*log(n)
D. about 4*log(n)
In a graph G, F is a spanning forest of G if
(i)F is a subgraph of G containing all the nodes of G
(ii)F is an order forest containing trees T1,T2,...Tn
(iii)Ti contains all the nodes that are reachable in G from the root Ti and are contained in Tj for some j
Which of the above conditions is/are true?
A. (i),(ii)
B. (ii),(iii)
C. (i),(iii)
D. (i),(ii) and (iii)
A. Current depth of recursion
B. Formal parameters
C. Location where the function should return when done
D. Local variables
A. conceptually easier and completely dynamic
B. efficient if the sparse matrix is a band matrix
C. efficient in accessing an entry
D. all of these
A. Overflow
B. Underflow
C. Collision
D. None of the above
A. Post-order traversal of the left sub tree
B. Post-order traversal of the right sub tree
C. Post-order traversal of the root
D. Post-order traversal of the lowest node
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 but stacks use only one
D. Stacks use two ends of the structure but queues use only one
A. Pre-order traversal
B. Post-order traversal
C. In order traversal
D. Top-down traversal
A. At the head
B. At the tail
C. After all other entries that are greater than the new entry
D. After all other entries that are smaller than the new entry
A. Constant
B. Linear
C. Logarithmic
D. Quadratic
A. 4
B. 8
C. 11
D. 15
A. Both are planar
B. Neither is a planar
C. Both are isomorphic
D. None of these
A. all zeros
B. all ones
C. both zeros and ones
D. different
A. O(1)
B. O(log2n)
C. O(n)
D. O(n*log2n)