Question 1
Which of the following sorting algorithms works best on a nearly sorted array?
1
Selection Sort
2
Quick Sort
3
Bubble Sort
4
Insertion Sort
Question 2
What is the time complexity of merging two sorted arrays of sizes m and n?
1
O(log(m + n))
2
O(m * n)
3
O(1)
4
O(m + n)
Question 3
What is the space complexity of the merge sort algorithm for sorting an array?
1
O(n)
2
O(log n)
3
O(1)
4
O(n log n)
Question 4
In which case does the time complexity of Quick Sort become O(n²)?
1
When the pivot is always the median
2
When the array contains duplicate values
3
When the pivot is chosen randomly
4
When the array is already sorted and the first or last element is chosen as the pivot
Question 5
Which sorting algorithm works best for small datasets and is easy to implement?
1
Bubble Sort
2
Insertion Sort
3
Quick Sort
4
Merge Sort
Question 6
Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
1
Insertion Sort
2
Quick Sort
3
Merge Sort
4
Heap Sort
Question 7
What is the time complexity of finding an element in a sorted array using binary search?
1
O(log n)
2
O(n)
3
O(1)
4
O( n log n)
Question 8
What is the purpose of Array.Sort(arr)?
1
Deletes array
2
Sorts the array in ascending order
3
Initializes array
4
Converts to string
