4. Software Development
Algorithms — Quiz
Test your understanding of algorithms with 5 practice questions.
Practice Questions
Question 1
Which of the following best describes the time complexity of the Heap Sort algorithm in the worst case?
Question 2
Consider the following pseudocode:
1. Let low = 0
2. Let high = length of array - 1
3. While low < high
4. If array[low] > array[high], swap array[low] and array[high]
5. Increment low
6. Decrement high
What is the primary purpose of this algorithm?
1. Let low = 0
2. Let high = length of array - 1
3. While low < high
4. If array[low] > array[high], swap array[low] and array[high]
5. Increment low
6. Decrement high
What is the primary purpose of this algorithm?
Question 3
Which of the following best describes the time complexity of the iterative version of the Fibonacci sequence algorithm?
Question 4
Which of the following algorithms is most suitable for finding the shortest path in a weighted graph with non-negative edge weights?
Question 5
Consider the following algorithm:
1. Select a 'pivot' element from the array
2. Partition the array into two subarrays: elements less than the pivot and elements greater than the pivot
3. Recursively apply the above steps to the subarrays
4. Combine the subarrays and the pivot into a sorted array
What is the average-case time complexity of this algorithm?
1. Select a 'pivot' element from the array
2. Partition the array into two subarrays: elements less than the pivot and elements greater than the pivot
3. Recursively apply the above steps to the subarrays
4. Combine the subarrays and the pivot into a sorted array
What is the average-case time complexity of this algorithm?
