Data Structure All MCQS
Data Structure All MCQS
An array is a data structure that stores a collection of elements, each identified by an index, and
all elements are of the same data type.
Related MCQS
What is the primary characteristic of an array?
a. Through a key.
b. Through an index.
c. Through a pointer.
d. Through a label.
What is the typical starting index of elements in most programming languages' arrays?
a. 1
b. 0
c. -1
d. It varies between programming languages.
a. Set
b. Queue
c. List
d. Array
a. 9
b. 10
c. 11
d. 9
a. O(log n)
b. O(1)
c. O(n)
d. O(n^2)
Which type of array allows you to change its size dynamically as elements are added or removed?
a. Static array
b. Dynamic array
c. Linked list
d. Queue
Insertion Sort
Insertion sort is a sorting algorithm that repeatedly takes an element and inserts it into its correct
position within a partially sorted array.
Related MCQS
What is the primary characteristic of the Insertion sort algorithm?
In the worst-case scenario, what is the time complexity of the Insertion sort algorithm for sorting an
array of 'n' elements?
a. O(n)
b. O(n^2)
c. O(log n)
d. O(n log n)
a. Quick sort
b. Merge sort
c. Heap sort
d. Insertion sort
a. It is difficult to implement.
a. None
a. O(n)
b. O(n)
c. O(n^2)
d. O(log n)
Which step of the Insertion sort algorithm involves shifting elements to make room for the newly
inserted element?
a. Comparison
b. Swapping
c. Partitioning
d. Merging
What is the primary benefit of using Insertion sort over other sorting algorithms like Quick sort or Merge
sort?
In Insertion sort, what is the order in which elements are compared and moved?
a. Largest to smallest
b. Smallest to largest
c. Left to right
d. Right to left
Selection sort
Selection sort is a sorting algorithm that repeatedly selects the minimum element from an
unsorted portion of a list and moves it to the sorted portion.
Related MCQS
What is the primary characteristic of the Selection sort algorithm?
In terms of time complexity, how does Selection sort perform compared to other sorting
algorithms?
b. It has a time complexity of O(n^2), making it less efficient for large datasets.
In the Selection sort algorithm, how are elements compared during the selection process?
b. Elements are compared for their relative order, and swapping is done if needed.
Which step of the Selection sort algorithm involves finding the minimum (or maximum) element
in the unsorted portion of the list?
a. Swapping
b. Partitioning
c. Merging
d. Selection
What is the typical time complexity for Selection sort in the best-case scenario?
a. O(n)
b. O(n^2)
c. O(log n)
d. O(n log n)
In Selection sort, does it matter whether you start with the minimum or maximum element in
the unsorted portion?
What is the primary benefit of using Selection sort over other sorting algorithms?
Which step of Selection sort involves moving the selected minimum (or maximum) element to
its correct position in the sorted portion of the list?
a. Swapping
b. Selection
c. Partitioning
d. Insertion
a. O(n)
b. O(n^2)
c. O(log n)
d. O(n log n)
What is the main advantage of Selection sort over other sorting algorithms like Quick sort or
Merge sort?
In the Selection sort algorithm, how many elements are initially considered as the sorted portion
of the array?
a. None
In the Selection sort algorithm, how many elements are considered in each comparison to find
the minimum (or maximum) element?
a. One
b. Multiple
c. None
a. It is complex to implement.
b. It is not a comparison-based sorting algorithm.
Bubble Sort
Bubble sort is like sorting playing cards in your hand. You compare adjacent cards and swap them
if they're not in order, repeating until all the cards are sorted.
Related MCQS
What is the primary characteristic of the Bubble sort algorithm?
In terms of time complexity, how does Bubble sort perform compared to other sorting
algorithms?
b. It has a time complexity of O(n^2), making it less efficient for large datasets.
In the Bubble sort algorithm, which step involves comparing and swapping adjacent elements to
move the largest element to the end of the list?
a. Selection
b. Sorting
c. Merging
d. Partitioning
What is the typical time complexity for Bubble sort in the best-case scenario?
a. O(n)
b. O(n^2)
c. O(log n)
d. O(n log n)
What is the main advantage of using Bubble sort over other sorting algorithms like Quick sort or
Merge sort?
In the Bubble sort algorithm, how many elements are initially considered as the sorted portion
of the list?
a. None
In the Bubble sort algorithm, how are elements compared during the sorting process?
a. Elements are compared for their relative order, and swapping is done if needed.
a. It is complex to implement.
Redix Sort
Radix sort organizes numbers by looking at their digits one at a time, from right to left (or left to
right), and places them in the right order.
Related MCQS
What is the primary characteristic of the Radix sort algorithm?
What is the time complexity of Radix sort for sorting 'n' elements with 'k' digits in the largest
number?
a. O(n)
b. O(k * n)
c. O(n^2)
d. O(n log n)
In Radix sort, which digit is considered first for sorting when processing numbers from right to
left?
c. When the range of digits is limited, and numbers have the same number of digits.
What is the primary advantage of Radix sort over comparison-based sorting algorithms like
Quick sort?
b. It has a linear time complexity in certain cases and is not based on comparisons.
a. It is not stable.
c. It is not suitable for all types of data and has a high time complexity in some cases.
d. It is challenging to implement.
Bucket Sort
Bucket Sort is a sorting algorithm that divides elements into buckets and sorts each bucket
individually.
MCQS
What is the primary characteristic of the Bucket Sort algorithm?
Which sorting algorithm is often used to sort the individual buckets in Bucket Sort?
a. Quick Sort
b. Merge Sort
c. Bubble Sort
d. Selection Sort
a. O(1)
b. O(log n)
c. O(n)
d. O(n^2)
a. O(1)
b. O(log n)
c. O(n)
d. O(n^2)
In Bucket Sort, when elements are distributed into buckets, how does the distribution work?
a. Randomly
c. In a fixed order
d. In reverse order
Which step follows the distribution of elements into buckets in the Bucket Sort algorithm?
a. Merging the buckets
d. Re-distributing elements
a. O(1)
b. O(log n)
c. O(n)
d. O(n^2)
Shell Sort
Shell Sort is a sorting algorithm that progressively narrows the gap between elements to be
sorted, leading to improved performance.
MCQS
What type of sorting algorithm is Shell Sort?
a. Stable sort
b. Quick sort
c. In-place sort
d. Selection sort
In Shell Sort, what is the main idea behind its approach to sorting?
b. Start with the smallest gap between elements and successively reduce the gap.
c. Use a pivot element to partition the array.
a. O(1)
b. O(n)
c. O(n log n)
d. O(n^2)
a. Bubble Sort
b. Merge Sort
c. Quick Sort
d. Insertion Sort
What is the term for the gap between elements in Shell Sort that gets successively reduced?
a. Span
b. Step
c. Stride
d. Increment
In Shell Sort, which gap sequence is commonly used to determine the gaps between elements?
a. Fibonacci sequence
b. Geometric progression
c. Arithmetic sequence
d. Sedgewick's sequence
a. O(1)
b. O(log n)
c. O(n)
d. O(n log n)
In Shell Sort, what is the last step after narrowing the gaps between elements?
d. Re-distributing elements
Which sorting algorithm is commonly used in the final step of Shell Sort for small subarrays?
a. Quick Sort
b. Merge Sort
c. Insertion Sort
d. Bubble Sort
Merge Sort
Merge Sort is a sorting algorithm that divides an unsorted list into smaller, sorted lists and then
merges them to produce a fully sorted list. It has a consistent O(n log n) time complexity.
MCQS
What is the primary characteristic of Merge Sort?
b. In-place sorting
c. Divide-and-conquer strategy
d. Bubble sort
In Merge Sort, how are subarrays merged into a single sorted array?
a. O(1)
b. O(n)
c. O(n log n)
d. O(n^2)
In Merge Sort, what's the term for the individual, sorted lists that are merged together?
a. Sections
b. Segments
c. Sublists
d. Partitions
What is the term for the process of dividing the unsorted list into smaller subarrays in Merge
Sort?
a. Splitting
b. Shuffling
c. Merging
d. Inserting
a. O(1)
b. O(n log n)
c. O(n)
d. O(n^2)
a. Quick sort
b. Bubble sort
c. Divide-and-conquer sort
d. Selection sort
In Merge Sort, what is the term for combining two sorted subarrays into a single sorted array?
a. Shuffling
b. Arranging
c. Merging
d. Inserting
b. Divide the array into smaller subarrays, sort them, and then merge the sorted subarrays.
MIXED MCQS
Which sorting algorithm divides the array into two halves, sorts them, and then merges the
sorted halves?
a. Quick Sort
b. Insertion Sort
c. Merge Sort
d. Radix Sort
a. O(1)
b. O(n)
c. O(n log n)
d. O(n^2)
b. Divide-and-conquer strategy
c. In-place sorting
d. Simple and easy-to-understand approach
a. Merge Sort
b. Selection Sort
c. Quick Sort
d. Insertion Sort
Which sorting algorithm is suitable for sorting large datasets and is often used as an external
sorting method?
a. Bucket Sort
b. Merge Sort
c. Insertion Sort
d. Shell Sort
c. It repeatedly selects the smallest (or largest) element and moves it to its correct position.
b. It distributes elements into a set of buckets and then sorts each bucket individually.
In Shell Sort, what is the term for the gap between elements that gets successively reduced?
a. Span
b. Increment
c. Step
d. Stride
Which sorting algorithm is known for its consistent O(n log n) time complexity and stable sorting
behavior?
a. Insertion Sort
b. Shell Sort
c. Merge Sort
d. Radix Sort
d. Complexity of implementation
In which sorting algorithm does the "insertion" step involve shifting elements to make room for
the next element to be inserted in its correct place?
a. Selection Sort
b. Quick Sort
c. Merge Sort
d. Insertion Sort
a. O(n)
b. O(1)
c. O(n log n)
d. O(n^2)
In Merge Sort, what is the term for the individual, sorted lists that are merged together?
a. Sections
b. Sublists
c. Segments
d. Partitions
Which part of the Merge Sort algorithm divides the unsorted list into smaller subarrays?
a. Shuffling
b. Splitting
c. Merging
d. Inserting
What is the term for the gap between elements in Shell Sort that gets successively reduced?
a. Span
b. Stride
c. Step
d. Increment
a. O(1)
b. O(n log n)
c. O(n)
d. O(n)
In Radix Sort, what is the term for the maximum number of digits present in the elements being
sorted?
a. Spread
b. Range
c. Maximum Radix
d. Spread Factor
RECURSION
Recursion is a programming concept where a function calls itself to solve a problem by breaking it
down into smaller, similar subproblems.
MCQS
What is recursion in programming?
a. A loop
b. A base case
c. A global variable
d. A library function
b. To improve readability
c. To handle exceptions
b. Array
c. Tree
d. Graph
What is the term for a situation in which a recursive function calls itself indefinitely without
reaching a base case?
a. Stack overflow
b. Infinite recursion
c. Recursion error
d. Infinite loop
a. Improved performance
d. To handle exceptions
STACKS
Stacks are linear data structures with a Last In, First Out (LIFO) order, where elements are added
and removed from the top end.
MCQS
a. Bottom end
b. Middle
c. Top end
d. Randomly
a. Push
b. Pop
c. Peek
d. Remove
Which operation in a stack is used to remove the top element?
a. Push
b. Peek
c. Pop
d. Insert
Which data structure does a stack most closely resemble in terms of behavior?
a. Queue
b. List
c. Tree
d. Array
a. Head
b. Pointer
d. Tail
b. Expression evaluation
c. Graph traversal
What happens when you try to pop an element from an empty stack?
a. It throws an error.
Which operation in a stack allows you to view the top element without removing it?
a. Push
b. Pop
c. Peek
d. Top
What is the time complexity of push and pop operations in a typical stack?
QUEUES
Queues are linear data structures that operate under the First In, First Out (FIFO) principle, where
elements are added to the back and removed from the front.
MCQS
What is the fundamental principle that queues follow?
a. Front(removed)
b. Middle
c. Back(added)
d. Randomly
a. Enqueue
b. Dequeue
c. Peek
d. Insert
Which operation in a queue is used to remove the front element?
a. Enqueue
b. Peek
c. Dequeue
d. Remove
Which data structure does a queue most closely resemble in terms of behavior?
a. Stack
b. List
c. Tree
d. Line
a. Head
b. Pointer
d. Tail
a. Task scheduling
b. Process management
c. Expression evaluation
What happens when you try to dequeue an element from an empty queue?
a. It throws an error.
Which operation in a queue allows you to view the front element without removing it?
a. Enqueue
b. Dequeue
c. Peek
d. Front
What is the time complexity of enqueue and dequeue operations in a typical queue?