Tuesday, November 21, 2023

Inplace sorting algorithm which requires minimum number of swaps?


 Answer: Selection Sort

Selection Sort is an in-place algorithm having minimum number of swaps.

In selection sort the maximum swaps which can take place are O(n).

 

In computer science, an in-place algorithm is an algorithm that operates directly on the input data structure without requiring extra space.

In-place means that the algorithm does not use extra space for manipulating the input but may require a small though non-constant extra space for its operation.

Bubble sort, selection sort, insertion sort, heapsort, and Shell sort are examples of in-place sorting algorithms.


0 comments:

Post a Comment

Data Structures with C++



NET/SET/CS PG



Operating Systems



Computer Networks



JAVA



Design and Analysis of Algorithms



Programming in C++

Top