in GATE retagged by
618 views
0 votes
0 votes

We write a new algorithm by considering the fact that number of comparisons required by Selection Sort can be reduced by considering elements in pairs and finding the minimum and maximum element at the same time.

What will be the time complexity of the new algorithm for comparisons of Selection Sort?

  1.    $O/2$
  2.    $O(n)/4$
  3.    $O(n)$
  4.    $O$$(\log n)$
in GATE retagged by
by
618 views

2 Comments

options are not clear.
1
1
Selection sort usually takes $\frac{n^2}{2}$ comparisons.

I believe by taking pairs, we'll reduce the comparisons by a factor of 2 (ie $\frac{n^2}{4}$)

This is still $O(n^2)$

 

What did I miss? :(
0
0

1 Answer

1 vote
1 vote
Best answer
The new algorithm will only reduce the number of comparisons but will not reduce the complexity.
selected by

4 Comments

Bikram sir

no of comparisions will be O(n2).

So why we are getting time complexity of O(n)?

Also according to the provided link above https://www.macs.hw.ac.uk/~pjbk/pathways/cpp2/node67.html

1
1

@kash0611

The screenshot you posted doesn't mention about the modification being done here in the question. This is the unmodified version right..?

Also the link is broken..

@Bikram Sir, please elaborate a bit..

0
0

@Bikram Sir, Can you please elaborate how the element pair will reduce the comparison complexity (by taking any example) because I think that even if we take pair we will still need each element to compare with the current_max and current_min element , which would make the comparisons same.

my thinking may not be correct, so please correct me !

@GO_user

0
0
Answer:

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

64.3k questions

77.9k answers

244k comments

80.0k users