Interview Questions and Quiz on Bubble Sort Algorithm Set 1

This quiz series is on the bubble sort algorithm. These are very common questions that can be used for refreshing your knowledge. This is quiz no. 1 in this series.

Last Reviewed and Updated on February 7, 2020
Posted by Parveen(Hoven),
Aptitude Trainer and Software Developer

Quiz Questions

Each question has four choices. More than one options can be correct. When you have finished the quiz, click the button at the end of the questions to view the result, and the solutions and answers.


Your Score
Correct Answers:
Wrong Answers:
Unattempted:

Question 1

Which of the following signifies the worst case efficiency of bubble sort algorithm?
 A
O(n2)
 B
O(2n)
 C
O(n)
 D
O(nlog(n))
Soln.
Ans: A
O(n2), because the time taken to execute the algorithm increases quadratically with the increase in the size of the array

Question 2

What is the worst case space complexity of bubble sort algorithm?
 A
O(n2)
 B
O(2n)
 C
O(n)
 D
O(1)
Soln.
Ans: D
O(1) Auxiliary

Question 3

The process of traversing the entire list once is called a
 A
Pass
 B
List
 C
Both
 D
None
Soln.
Ans: A
Pass

Question 4

How many passes are required to sort an array with five elements by using the bubble sort algorithm?
 A
5
 B
4
 C
1
 D
None of the above
Soln.
Ans: B

Question 5

Which of the following signifies the average case efficiency of bubble sort algorithm?
 A
O(n2)
 B
O(2n)
 C
O(n)
 D
O(nlog n)
Soln.
Ans: A

Question 6

The given code is an example of which of the following sorting algorithm:
int s,t, numItems = 10;

for(s=(numItems - 1); s>=0; s--)
{

    for(t=1;t<=s;t++)
    {

        if(arr[t-1]>arr[t])
        {

            temp=arr[t-1];

            arr[t-1]=arr[t];

            arr[t]=temp;

        }

    }

}

 A
Selection Sort
 B
Bubble Sort
 C
Shell Sort
 D
None
Soln.
Ans: B

Question 7

How many passes are required to sort an array with five elements by using the bubble sort algorithm?
 A
0
 B
5
 C
4
 D
1
Soln.
Ans: C
4 because (n-1) passes is required where n=5

Question 8

How many comparisons are performed in third pass of the bubble sort algorithm?
 A
n - 2
 B
n - 1
 C
n - 3
 D
None
Soln.
Ans: C

Question 9

The process of traversing the entire list once is called a
 A
Pass
 B
List
 C
Both
 D
None
Soln.
Ans: A
Pass

Question 10

The efficiency of the selection sort algorithm is same as that of the bubble sort algorithm.
 A
False
 B
True
 C
Depends on List
 D
None
Soln.
Ans: B
True, because both have same order of growth.

My C/C++ Videos on Youtube

Here is the complete playlist for video lectures and tutorials for the absolute beginners. The language has been kept simple so that anybody can easily understand them. I have avoided complex jargon in these videos.