Bubble Sort MCQ Quiz

Reviewed by Godwin Iheuwa
Godwin Iheuwa, MS (Computer Science) |
Database Administrator
Review Board Member
Godwin Iheuwa, a Database Administrator at MTN Nigeria, holds an MS in Computer Science, specializing in Agile Methodologies and Database Administration from the University of Bedfordshire and a Bachelor's in Computer Science from the University of Port Harcourt. His proficiency in SQL Server Integration Services (SSIS) and SQL Server Management Studio contributes to his expertise in database management.
, MS (Computer Science)
By RosyU
R
RosyU
Community Contributor
Quizzes Created: 6 | Total Attempts: 43,117
| Attempts: 14,383 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. How many passes/scans will go through a list of 10 elements?

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.

Submit
Please wait...
About This Quiz
Bubble Sort MCQ Quiz - Quiz

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... see moreor 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.
see less

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

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.

Submit
3. In a bubble sort structure, there is/are?

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.

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

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. The algorithm gets its name because smaller elements "bubble" to the top of the list with each iteration.

Let's walk through the steps:

15, 20, 10, 18: In the first pass, we compare 15 and 20 (no swap), then 20 and 10 (swap to get 10, 20, 15, 18), and finally, 20 and 18 (no swap). The largest element, 20, bubbles up to the end.

10, 15, 20, 18: In the second pass, we compare 10 and 15 (no swap), then 15 and 20 (no swap), and finally 20 and 18 (swap to get 10, 15, 18, 20). Now, the second largest element, 15, is in its correct position.

10, 15, 18, 20: In the third pass, no swaps are needed as all elements are already in order.

So, the correct intermediate steps are:

15, 20, 10, 18

15, 10, 20, 18

10, 15, 20, 18

10, 15, 18, 20

This matches option C.
Submit
5. How many passes (or "scans") will there be through a list being sorted using a selection sort?

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.

Submit
6. Which one of the following is the first step in a selection sort algorithm?

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.

Submit
7. What is the maximum number of comparisons that can take place when a bubble sort is implemented? Assume there are n elements in the array?

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).

Submit
8. What are the worst case and best case time complexity of bubble sort consequently?

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).

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

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.

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

Explanation

Here’s how Bubble Sort would sort the list:

First pass: 8,7,22,5,13,931 (3 swaps: 22 and 7, 22 and 5, 22 and 13)

Second pass: 7,8,5,13,22,931 (2 swaps: 8 and 5, 8 and 13)

Third pass: 7,5,8,13,22,931 (1 swap: 7 and 5)

Fourth pass: 5,7,8,13,22,931 (0 swaps)

Fifth pass: 5,7,8,13,22,931 (0 swaps)

So, a total of 3 + 2 + 1 + 0 + 0 = 6 passes and 12 swaps are required to sort the list in ascending order. Please note that understanding the principles of algorithms, such as bubble sort, is crucial for effective software development. Always ensure to follow best coding practices when working with algorithms.

Submit
View My Results
Godwin Iheuwa |MS (Computer Science) |
Database Administrator
Godwin Iheuwa, a Database Administrator at MTN Nigeria, holds an MS in Computer Science, specializing in Agile Methodologies and Database Administration from the University of Bedfordshire and a Bachelor's in Computer Science from the University of Port Harcourt. His proficiency in SQL Server Integration Services (SSIS) and SQL Server Management Studio contributes to his expertise in database management.

Quiz Review Timeline (Updated): Mar 14, 2024 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 14, 2024
    Quiz Edited by
    ProProfs Editorial Team

    Expert Reviewed by
    Godwin Iheuwa
  • Dec 25, 2011
    Quiz Created by
    RosyU
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
How many passes/scans will go through a list of 10 elements?
Bubble sorting got its name from a Bubble gum company that used it for...
In a bubble sort structure, there is/are?
What are the correct intermediate steps of the following data set when...
How many passes (or "scans") will there be through a list...
Which one of the following is the first step in a selection sort...
What is the maximum number of comparisons that can take place when a...
What are the worst case and best case time complexity of bubble sort...
What is the maximum number of comparisons if there are 5 elements in...
When using Bubble sort, what number of swappings are required to sort...
Alert!

Advertisement