###### Programming

October 18, 2023###### 2014 June UGC NET Paper 1

October 18, 2023# GATE 2013

Question 6 |

Which one of the following is the tightest upper bound that represents the number of swaps required to sort n numbers using selection sort?

O(log n) | |

O(n) | |

O(n log n) | |

O(n ^{2}) |

Question 6 Explanation:

Best, Average and worst case will take maximum O(n) swaps.

Selection sort time complexity O(n

Selection sort time complexity O(n

^{2}) in terms of number of comparisons. Each of these scans requires one swap for n-1 elements (the final element is already in place).Correct Answer: B

Question 6 Explanation:

Best, Average and worst case will take maximum O(n) swaps.

Selection sort time complexity O(n

Selection sort time complexity O(n

^{2}) in terms of number of comparisons. Each of these scans requires one swap for n-1 elements (the final element is already in place). Subscribe

Login

0 Comments