(1) Selection Sort: Selection sort finds the minimum element in the unsorted portion and places it at the beginning. It does not compare neighboring elements and swap them repeatedly.
(2) Bubble Sort: Bubble sort repeatedly compares adjacent elements and swaps them if they are in the wrong order. This process bubbles the largest element to the end of the array in each pass.
(3) Insertion Sort: Insertion sort iterates through the array and inserts each element into its correct position in the sorted portion. It shifts elements as needed, but its primary operation is not solely comparing and swapping neighbors.
(4) Quick Sort: Quick sort is a divide-and-conquer algorithm that selects a pivot element and partitions the array around it. While there are comparisons and potentially swaps involved in partitioning, it doesn't only compare and swap neighboring elements.
Therefore, the algorithm that compares neighboring elements and swaps them when necessary is (2) Bubble Sort.
List-I (Words) | List-II (Definitions) |
(A) Theocracy | (I) One who keeps drugs for sale and puts up prescriptions |
(B) Megalomania | (II) One who collects and studies objects or artistic works from the distant past |
(C) Apothecary | (III) A government by divine guidance or religious leaders |
(D) Antiquarian | (IV) A morbid delusion of one’s power, importance or godliness |