feat(curriculum): add searching and sorting algorithm based questions (#56555)

This commit is contained in:
harshitaadam
2024-10-09 22:52:10 +05:30
committed by GitHub
parent 1a4d1e1506
commit db9ffd2507
@@ -17,439 +17,439 @@ Answer all of the questions below correctly to pass the quiz.
#### --text--
Placeholder question
What is the time complexity of binary search in the worst case?
#### --distractors--
Placeholder distractor 1
O(n)
---
Placeholder distractor 2
O(n^2)
---
Placeholder distractor 3
O(1)
#### --answer--
Placeholder answer
O(log n)
### --question--
#### --text--
Placeholder question
Which of the following is NOT a divide and conquer algorithm?
#### --distractors--
Placeholder distractor 1
Merge Sort
---
Placeholder distractor 2
Quick Sort
---
Placeholder distractor 3
Insertion Sort
#### --answer--
Placeholder answer
Bubble Sort
### --question--
#### --text--
Placeholder question
What is the time complexity of linear search in the worst case?
#### --distractors--
Placeholder distractor 1
O(log n)
---
Placeholder distractor 2
O(1)
---
Placeholder distractor 3
O(n log n)
#### --answer--
Placeholder answer
O(n)
### --question--
#### --text--
Placeholder question
Which sorting algorithm divides the array into smaller subarrays and merges them in sorted order?
#### --distractors--
Placeholder distractor 1
Quick Sort
---
Placeholder distractor 2
Insertion Sort
---
Placeholder distractor 3
Bubble Sort
#### --answer--
Placeholder answer
Merge Sort
### --question--
#### --text--
Placeholder question
What is the best-case time complexity of bubble sort?
#### --distractors--
Placeholder distractor 1
O(n^2)
---
Placeholder distractor 2
O(log n)
---
Placeholder distractor 3
O(n log n)
#### --answer--
Placeholder answer
O(n)
### --question--
#### --text--
Placeholder question
What is the time complexity of quicksort in the average case?
#### --distractors--
Placeholder distractor 1
O(n^2)
---
Placeholder distractor 2
O(n)
---
Placeholder distractor 3
O(log n)
#### --answer--
Placeholder answer
O(n log n)
### --question--
#### --text--
Placeholder question
What does divide and conquer refer to in algorithm design?
#### --distractors--
Placeholder distractor 1
Sorting elements one by one
---
Placeholder distractor 2
Searching through an array linearly
---
Placeholder distractor 3
Swapping adjacent elements
#### --answer--
Placeholder answer
Breaking a problem into smaller subproblems
### --question--
#### --text--
Placeholder question
Which of the following algorithms is the most efficient for large datasets in the average case?
#### --distractors--
Placeholder distractor 1
Bubble Sort
---
Placeholder distractor 2
Merge Sort
---
Placeholder distractor 3
Insertion Sort
#### --answer--
Placeholder answer
Quick Sort
### --question--
#### --text--
Placeholder question
In binary search, what condition is required for the array?
#### --distractors--
Placeholder distractor 1
The array must contain unique elements
---
Placeholder distractor 2
The array must be unsorted
---
Placeholder distractor 3
The array must have an even number of elements
#### --answer--
Placeholder answer
The array must be sorted
### --question--
#### --text--
Placeholder question
What is the space complexity of merge sort?
#### --distractors--
Placeholder distractor 1
O(log n)
---
Placeholder distractor 2
O(1)
---
Placeholder distractor 3
O(n^2)
#### --answer--
Placeholder answer
O(n)
### --question--
#### --text--
Placeholder question
What is the worst-case time complexity of bubble sort?
#### --distractors--
Placeholder distractor 1
O(n)
---
Placeholder distractor 2
O(n log n)
---
Placeholder distractor 3
O(1)
#### --answer--
Placeholder answer
O(n^2)
### --question--
#### --text--
Placeholder question
What is the best-case time complexity of binary search?
#### --distractors--
Placeholder distractor 1
O(n)
---
Placeholder distractor 2
O(log n)
---
Placeholder distractor 3
O(n^2)
#### --answer--
Placeholder answer
O(1)
### --question--
#### --text--
Placeholder question
Which of the following is a key characteristic of quicksort?
#### --distractors--
Placeholder distractor 1
It sorts elements in linear time
---
Placeholder distractor 2
It does not require recursion
---
Placeholder distractor 3
It splits arrays into two equal parts
#### --answer--
Placeholder answer
It uses pivot elements to partition arrays
### --question--
#### --text--
Placeholder question
What is the average-case time complexity of linear search?
#### --distractors--
Placeholder distractor 1
O(n^2)
---
Placeholder distractor 2
O(n log n)
---
Placeholder distractor 3
O(log n)
#### --answer--
Placeholder answer
O(n)
### --question--
#### --text--
Placeholder question
In quicksort, what happens when the pivot divides the array perfectly in half?
#### --distractors--
Placeholder distractor 1
The time complexity becomes O(n^2)
---
Placeholder distractor 2
The time complexity becomes O(n)
---
Placeholder distractor 3
The time complexity becomes O(log n)
#### --answer--
Placeholder answer
The time complexity becomes O(n log n)
### --question--
#### --text--
Placeholder question
What is the primary advantage of merge sort over quicksort?
#### --distractors--
Placeholder distractor 1
Merge sort has lower time complexity
---
Placeholder distractor 2
Merge sort has better space complexity
---
Placeholder distractor 3
Merge sort avoids recursion
#### --answer--
Placeholder answer
Merge sort has guaranteed O(n log n) performance in the worst case
### --question--
#### --text--
Placeholder question
Which sorting algorithm uses adjacent element comparisons and swaps?
#### --distractors--
Placeholder distractor 1
Quick Sort
---
Placeholder distractor 2
Merge Sort
---
Placeholder distractor 3
Selection Sort
#### --answer--
Placeholder answer
Bubble Sort
### --question--
#### --text--
Placeholder question
What is the time complexity of quicksort when the pivot is always the smallest or largest element?
#### --distractors--
Placeholder distractor 1
O(n)
---
Placeholder distractor 2
O(log n)
---
Placeholder distractor 3
O(n log n)
#### --answer--
Placeholder answer
O(n^2)
### --question--
#### --text--
Placeholder question
What does divide and conquer achieve in sorting algorithms?
#### --distractors--
Placeholder distractor 1
Improves space complexity
---
Placeholder distractor 2
Avoids recursion
---
Placeholder distractor 3
Works only on sorted arrays
#### --answer--
Placeholder answer
Allows subproblems to be solved recursively
### --question--
#### --text--
Placeholder question
What is the space complexity of quicksort in the best case?
#### --distractors--
Placeholder distractor 1
O(n)
---
Placeholder distractor 2
O(n log n)
---
Placeholder distractor 3
O(n^2)
#### --answer--
Placeholder answer
O(log n)