Uploaded by Chaudhry Jahangir

DSA mcqs

advertisement
What is an array?
A) A data structure that stores elements with different data types
B) A data structure that stores a collection of elements of the same data type
C) A data structure that stores elements in random order
D) A data structure that stores elements in a sorted order
(Answer: B)
Which of the following is an example of an unordered array?
A) [3, 1, 4, 2]
B) [1, 2, 3, 4]
C) [4, 3, 2, 1]
D) [1, 3, 2, 4]
(Answer: A)
In an ordered array, elements are arranged in:
A) Random order
B) Ascending or descending order
C) No specific order
D) Alphabetical order
(Answer: B)
What is a multidimensional array?
A) An array that can store multiple data types
B) An array that can store only integers
C) An array of arrays
D) An array with a single dimension
(Answer: C)
What is time complexity in the context of algorithms and data structures?
A) The amount of time it takes for an algorithm to run
B) The number of elements in an array
C) The number of comparisons made by an algorithm
D) The size of the data structure
(Answer: A)
In a stack, which operation allows you to remove an item from the top?
A) Push
B) Pop
C) Peek
D) Insert
(Answer: B)
Which data structure follows the Last-In-First-Out (LIFO) principle?
A) Queue
B) Stack
C) Linked list
D) Array
(Answer: B)
What is the time complexity of searching for an element in an unordered array of size N
using linear search?
A) O(1)
B) O(N)
C) O(log N)
D) O(N^2)
(Answer: B)
Which of the following is an example of a two-dimensional array?
A) [1, 2, 3]
B) [[1, 2], [3, 4]]
C) [1, [2, 3], 4]
D) [1, 2, 3, 4]
(Answer: B)
In the context of time complexity analysis, what does O(log N) represent?
A) Constant time
B) Linear time
C) Logarithmic time
D) Quadratic time
(Answer: C)
Which of the following statements is true about an ordered array?
A) It is always sorted in ascending order.
B) It is always sorted in descending order.
C) It can be sorted in any order.
D) It is not sorted.
(Answer: A)
What is the primary advantage of using an unordered array over an ordered array?
A) Faster search operations
B) Smaller memory usage
C) Easier insertion of new elements
D) More efficient sorting algorithms
(Answer: C)
In a two-dimensional array, how is data typically arranged?
A) In a single row
B) In a single column
C) In a grid with rows and columns
D) In a circular pattern
(Answer: C)
Which of the following is a common use case for a stack?
A) Maintaining a queue of tasks to be executed
B) Undo functionality in software applications
C) Storing elements in sorted order
D) Representing a graph data structure
(Answer: B)
What is the time complexity of inserting an element at the end of an ordered array of size
N?
A) O(1)
B) O(N)
C) O(log N)
D) O(N^2)
(Answer: B)
Which operation in a stack allows you to view the item at the top without removing it?
A) Push
B) Pop
C) Peek
D) Search
(Answer: C)
In a multidimensional array, how is each element uniquely identified?
A) By its value
B) By its position in the array
C) By its data type
D) By its index or indices
(Answer: D)
Which of the following sorting algorithms has the worst-case time complexity of O(N^2)?
A) Quick Sort
B) Merge Sort
C) Bubble Sort
D) Insertion Sort
(Answer: C)
What is the primary advantage of using a stack data structure over other data structures
like arrays or linked lists?
A) Constant-time access to any element
B) Efficient sorting operations
C) Last-In-First-Out (LIFO) behavior
D) Support for multidimensional data
(Answer: C)
In the context of time complexity, which notation represents the best-case scenario?
A) Big O (O)
B) Big Omega (Ω)
C) Big Theta (Θ)
D) Little O (o)
(Answer: B)
Download