Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
1.1k views
in Information Technology by (98.6k points)
closed by
The given array is arr = {1, 2, 4, 3}. Bubble sort is used to sort the array elements. How many passes will be done to sort the array?
1. 4
2. 2
3. 1
4. 3

1 Answer

0 votes
by (95.6k points)
selected by
 
Best answer
Correct Answer - Option 4 : 3

Concept

Bubble sort repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.

Explanation

Array elements: 1,2,4,3

1st pass = 1,2,4,3

1 and 2 not swap:

2nd pass = 1,2,4,3

2 and 4 not swap:

3rd pass = 1,2,4,3

4 and 3 swap:

Since array is sorted after 3th pass

Hence the answer is Option 4

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...