0% found this document useful (0 votes)
9 views4 pages

Selection Sort Quiz (With Ans Key)

The document is a quiz on Selection Sort, covering its advantages, disadvantages, time complexity, and characteristics. It includes multiple-choice questions that assess understanding of how Selection Sort operates, its stability, and its efficiency with different data types. Key concepts such as the number of passes, comparisons, and the sorting process are also addressed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Selection Sort Quiz (With Ans Key)

The document is a quiz on Selection Sort, covering its advantages, disadvantages, time complexity, and characteristics. It includes multiple-choice questions that assess understanding of how Selection Sort operates, its stability, and its efficiency with different data types. Key concepts such as the number of passes, comparisons, and the sorting process are also addressed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Selection Sort Quiz

Reported by: Mabalot, Katherine F. & Marcelo, Nicole A.

1. Why is Selection Sort considered good for small datasets?


A. It has a low time complexity for large datasets.
B. It uses minimal memory and is simple to implement.
C. It always produces a stable sort.
D. It performs better than all other sorting algorithms.

2. What determines the time complexity of Selection Sort?


A. The number of swaps performed.
B. The number of comparisons, which is independent of the input order.
C. The size of the largest element in the dataset.
D. The memory required to store the sorted data.

3. What type of data can Selection Sort handle?


A. Only numbers.
B. Only strings.
C. Any data that can be compared, such as numbers, strings, or custom objects.
D. Only pre-sorted data.

4. Why is Selection Sort not considered a stable sorting algorithm?


A. It modifies the relative order of elements with equal keys during sorting.
B. It always uses extra memory to store sorted data.
C. It only works with numerical data.
D. It requires input data to be sorted beforehand.

5. In which scenario is the worst-case performance of Selection Sort observed?


A. When the input is already sorted.
B. When the input is in reverse sorted order.
C. When the input contains duplicate elements.
D. When the input is a mix of sorted and unsorted data.

6. How does Selection Sort place elements into their correct positions?
A. By shifting elements instead of swapping them.
B. By directly swapping the smallest unsorted element with the first element of the unsorted
portion.
C. By recursively dividing the dataset into smaller portions.
D. By merging multiple sorted subsets.

7. Why is Selection Sort considered an in-place sorting algorithm?


A. It uses additional memory to store the sorted array.
B. It requires no extra memory apart from the input array.
C. It operates by creating new subarrays for sorting.
D. It uses external storage for intermediate results.
8. Is Selection Sort considered a stable sorting algorithm? Why or why not?
A. Yes, because it preserves the relative order of equal elements.
B. No, because it may change the relative order of equal elements.
C. Yes, because it only works with unique keys.
D. No, because it requires extra memory to handle duplicates.

9. How does Selection Sort organize the input array during sorting?
A. By dividing it into a sorted and unsorted portion.
B. By creating multiple subarrays.
C. By first sorting the largest elements and then the smallest.
D. By swapping elements randomly until sorted.

10. What is a key characteristic of Selection Sort regarding comparisons?


A. The number of comparisons depends on the input order.
B. The number of comparisons increases exponentially with the array size.
C. The number of comparisons is the same, regardless of input order.
D. The number of comparisons decreases for sorted data.

11. In a selection sort structure, there is/are?

A. Two separate for loops

B. Three for loops, all separate

C. Two for loops, one nested in the other

D. A for loop nested inside a while loop

12. What are the correct intermediate steps of the following data set when it is being sorted
with the Selection sort? 15,20,10,18

A.10, 20,15,18 -- 10,15,20,18 -- 10,15,18,20

B.15,20,10,18 -- 15,10,20,18 -- 10,15,20,18 -- 10,15,18,20

C.15,18,10,20 -- 10,18,15,20 -- 10,15,18,20 -- 10,15,18,20

D.15,10,20,18 -- 15,10,18,20 -- 10,15,18,20

13. How many passes (or "scans") will there be through a list being sorted using a selection
sort?

A.Array_size*2

B.Array_size+1

C.Array_size-1

D.None of the above

Explanation
In a selection sort, each pass involves finding the minimum element from the unsorted part of the
list and swapping it with the first element of the unsorted part. After each pass, the sorted part of
the list increases by one element. Since there are a total of array_size elements in the list, it will
take array_size-1 passes to sort the entire list.

14. How many passes/scans will go through a list of 10 elements?

A.11

B.9

C.20

D.25

Explanation
Since there are 10 elements in the list, each pass/scan will go through one element. Therefore,
there will be a total of 10 passes/scans. However, the question is asking for the number of
passes/scans, not the number of elements. Therefore, the correct answer is 9, as the first
pass/scan is not counted.

15. Select the appropriate code that performs selection sort.

a. b.

c. d.
16. What is the advantage of selection sort over other sorting techniques?
a) It requires no additional storage space
b) It is scalable
c) It works best for inputs which are already sorted
d) It is faster than any other sorting technique

17. What is the disadvantage of selection sort?


a) It requires auxiliary memory
b) As the input size increases, the performance of selection sort decreases.
c) It can be used for small keys
d) It takes linear time to sort the elements

18. What is the best case complexity of selection sort?


a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)

19. Which of the following is the correct steps in selection sort?

A. Start with the first element of the array.

B. Move the boundary between the sorted and unsorted portions one step forward.

C. Swap the smallest element with the first element of the unsorted portion.

D. Repeat until the entire array is sorted.

E. Find the smallest element in the unsorted portion of the array.

a. B, C, A , D, E

b. E, A, C, B, D

c. E, A, B, C, D

d. A, E, C, B, D

20. What is the worst case complexity of selection sort?


a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)

You might also like