Question:medium

__________ compares neighboring elements only and swaps them when necessary?

Updated On: Jan 16, 2026
  • Selection Sort
  • Bubble Sort
  • Insertion Sort
  • Quick Sort
Show Solution

The Correct Option is B

Solution and Explanation

(1) Selection Sort: Selection sort identifies the minimum element within the unsorted segment and positions it at the start. It avoids iterative comparison and swapping of adjacent elements.

(2) Bubble Sort: Bubble sort sequentially compares neighboring elements. If an adjacent pair is out of order, they are swapped. This action effectively moves the largest element to the array's end with each iteration.

(3) Insertion Sort: Insertion sort processes the array element by element, placing each into its rightful spot within the already sorted section. While it involves shifting elements, its core function isn't solely the comparison and swapping of adjacent items.

(4) Quick Sort: Quick sort employs a divide-and-conquer strategy, choosing a pivot and reorganizing the array around it. Although partitioning involves comparisons and potential swaps, it is not exclusively about comparing and swapping adjacent elements.

Consequently, the algorithm characterized by comparing and swapping adjacent elements when they are in the wrong order is (2) Bubble Sort.

Was this answer helpful?
0


Questions Asked in CUET (UG) exam