Question: / / FIXME ( 1 a ) : Implement the selection sort logic over bid.title / * * * Perform a selection sort on bid
FIXME a: Implement the selection sort logic over bid.title
Perform a selection sort on bid title
Average performance: On
Worst case performance On
@param bid address of the vector
instance to be sorted
void selectionSortvector& bids
define min as int index of the current minimum bid
int i ;
int j ;
int indexSmallest ;
int temp ;
check size of bids vector
set sizet platformneutral result equal to bid.size
for i ; i bids.size; i
indexSmallest i;
for j i ; j bids.size; j
if bidsj bidsindexSmallest
indexSmallest j;
Bid temp bidsi;
bidsi bidsindexSmallest;
bidsindexSmallest temp;
pos is the position within bids that divides sortedunsorted
for sizet pos and less than size
set min pos
loop over remaining elements to the right of position
if this element's title is less than minimum title
this element becomes the minimum
swap the current minimum with smaller one found
swap is a built in vector method
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
