# Subjective Interview Questions on Bubble Sort Set 2

## Subjective, long answer type interview questions for freshers on bubble sort. These questions have been asked in interviews for MNCs like Wipro, TCS and Infosys. This is subjective type short answers question and answer set no. 2 in this series.

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

## Interview and Exam Questions and Answers

This set contains a list of commonly asked questions. They are short interview questions aimed at freshers interview, campus placement drives, and also for job interviews. You can use these to have a quick grasp and brush-up of your fundamentals. These questions can be viewed on a mobile phone also because this website is built on responsive web design.

## What are the basic criteria for selecting appropriate algorithm?

1. Execution Time.
2. Storage Space.
3. Programming Effort.

## Is this code for bubble sort or not ?

```void DoBubbleSort ()
{

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;

}

}

}

}

```
Yes, the code is for bubble sort.

## What is worst case and average case of bubble sort algorithm?

Worst case = O(n2) and average case = O(n2).

## While implementing the bubble sort algorithm, how many comparisons will performed in Pass 1?

n - 1 comparisons.

## What is the complexity of the bubble sort algorithm?

The complexity is O(n2). The time required to execute the bubble sort algorithm is proportional to (n2), where n is the number of input items.

## Bubble sort is used for large or small list.

Bubble sort is used for small list.

## What is the worst case scenario for bubble sort, and why?

The worst situation for bubble sort is when the list's smallest element is in the last position. In this situation, the smallest element will move down one place on each pass through the list, meaning that the sort will need to make the maximum number of passes through the list, namely n - 1.

## What is best case performance of bubble sort algorithm?

The best case performance of bubble sort algorithm is O(n).

## Do bubble sort and selection sort have quadratic order of growth?

Yes, bubble sort and selection sort have quadratic order of growth.

## What are the problems in the bubble sort?

The bubble sort have Turtles and rabbits problem. Because big elements (rabbits) go up fast, while small ones (turtles) go down very slow.

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