# Bubble Sort MCQ Quiz

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
| By RosyU
R
RosyU
Community Contributor
Quizzes Created: 6 | Total Attempts: 40,694
Questions: 10 | Attempts: 13,719  Settings  Here is an amazing Bubble sort Quiz. You can also call it a selection sort quiz. This Quiz is to check your knowledge of the Bubble sort algorithm or selection sort algorithm. If you think you understand enough about the Bubble sort algorithm and you can pass this test with a good score, then try your luck here. If you manage to get 80 or above in this selection sort quiz, that would be excellent—best of luck with your test here.

• 1.

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

• A.

15,10,20,18 -- 15,10,18,20 -- 10,15,18,20

• B.

10, 20,15,18 -- 10,15,20,18 -- 10,15,18,20

• C.

15,20,10,18 -- 15,10,20,18 -- 10,15,20,18 -- 10,15,18,20

• D.

15,18,10,20 -- 10,18,15,20 -- 10,15,18,20 -- 10,15,18,20

A. 15,10,20,18 -- 15,10,18,20 -- 10,15,18,20
Explanation
The given answer shows the correct intermediate steps of the bubble sort algorithm for sorting the data set 15, 20, 10, 18. The first step is to compare the first two elements, 15 and 20, and swap them if they are in the wrong order. Then, the algorithm moves to the next pair, 20 and 10, and swaps them. After that, it compares 20 and 18 and swaps them again. This completes the first pass of the algorithm. In the second pass, the algorithm starts again from the beginning and repeats the same steps until the data set is fully sorted.

Rate this question:

• 2.

### In a bubble sort structure, there is/are?

• A.

A single for loop

• B.

Three for loops, all separate

• C.

A while loop

• D.

Two for loops, one nested in the other

D. Two for loops, one nested in the other
Explanation
The correct answer is two for loops, one nested in the other. In a bubble sort structure, the outer loop iterates through the entire array, while the inner loop compares adjacent elements and swaps them if they are in the wrong order. This process is repeated until the array is sorted.

Rate this question:

• 3.

### What is the maximum number of comparisons if there are 5 elements in array x?

• A.

10

• B.

2

• C.

5

• D.

25

A. 10
Explanation
If there are 5 elements in array x, the maximum number of comparisons can be calculated using the formula n*(n-1)/2, where n is the number of elements in the array. In this case, n=5, so the maximum number of comparisons is 5*(5-1)/2 = 10.

Rate this question:

• 4.

### What is the max number of comparisons that can take place when a bubble sort is implemented? Assume there are n elements in the array?

• A.

(1/2)(n-1)

• B.

(1/2)n(n-1)

• C.

(1/4)n(n-1)

• D.

None of the above

B. (1/2)n(n-1)
Explanation
The maximum number of comparisons that can take place when a bubble sort is implemented is (1/2)n(n-1). In a bubble sort, each element is compared with its adjacent element and swapped if necessary. The number of comparisons decreases by 1 with each pass through the array, as the largest element "bubbles" to its correct position. Therefore, the total number of comparisons can be calculated by summing the numbers from 1 to n-1, which is equal to (1/2)n(n-1).

Rate this question:

• 5.

### What are the worst case and best case time complexity of bubble sort consequently?

• A.

O(n), O(n2)

• B.

O(n2), O(n3)

• C.

O(n), O(n3)

• D.

None of the above

A. O(n), O(n2)
Explanation
Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. In the best case scenario, when the list is already sorted, the algorithm only needs to make one pass through the list to confirm that it is sorted, resulting in a time complexity of O(n). However, in the worst case scenario, when the list is in reverse order, the algorithm needs to make n-1 passes through the list and perform comparisons and swaps at each step, resulting in a time complexity of O(n^2).

Rate this question:

• 6.

### Which one of the following is the first step in a selection sort algorithm?

• A.

The minimum value in the list is found.

• B.

The maximum value in the list is found.

• C.

A. The minimum value in the list is found.
Explanation
In a selection sort algorithm, the first step is to find the minimum value in the list. This is done by comparing each element with the current minimum value and updating the minimum value if a smaller element is found. Once the minimum value is found, it is swapped with the first element in the list. This process is repeated for the remaining elements in the list, finding the minimum value and swapping it with the next element. This continues until the list is sorted in ascending order.

Rate this question:

• 7.

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

• A.

3

• B.

5

• C.

7

• D.

9

D. 9
Explanation
In order to go through a list of 10 elements, we need to iterate over each element once. This requires a single pass or scan. However, the answer provided is 9, which is incorrect. It is possible that the question is incomplete or there is missing information that would justify the answer of 9. Without further context, it is not possible to provide a clear explanation for this answer.

Rate this question:

• 8.

### Bubble sorting got its name from a Bubble gum company that used it for the first time.

• A.

True

• B.

False

B. False
Explanation
The given statement is false. Bubble sorting is a simple sorting algorithm that works by repeatedly swapping adjacent elements if they are in the wrong order. It is called "bubble sorting" because during each iteration, the largest unsorted element "bubbles" up to its correct position in the sorted portion of the array. The statement about a Bubble gum company using it for the first time is not true.

Rate this question:

• 9.

### 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

C. Array_size-1
Explanation
The number of passes or scans through a list being sorted using selection sort is equal to the size of the array minus one. In each pass, the algorithm selects the smallest element from the unsorted portion of the list and swaps it with the first unsorted element. This process is repeated until the entire list is sorted. Since the last element does not need to be compared with any other elements, there is no need for a final pass. Therefore, the number of passes is equal to the size of the array minus one.

Rate this question:

• 10.

### When using Bubble sort, what number of swappings are required to sort the numbers 8,22,7,931,5,13 in ascending order?

• A.

5

• B.

10

• C.

12

• D.

14

B. 10
Explanation
Bubble sort works by repeatedly swapping adjacent elements if they are in the wrong order. In this case, the numbers 8, 22, 7, 931, 5, and 13 need to be sorted in ascending order. The first pass of bubble sort would compare 8 and 22, swap them, then compare 22 and 7, swap them, and so on until the largest number, 931, is in its correct position. This would require 4 swaps. The second pass would compare and swap the remaining numbers until the second largest number, 22, is in its correct position. This would require 3 swaps. The third pass would require 2 swaps, the fourth pass would require 1 swap, and the fifth pass would require no swaps as the numbers are already in ascending order. Therefore, a total of 10 swaps are required to sort the given numbers.

Rate this question:

Related Topics Back to top