Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ / 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started