Write a pseudocode for the following.
void selectionSort(vector& bids) {
unsigned min;
for (unsigned pos = 0; pos < bids.size();="" ++pos)="">
min = pos;
for (unsigned j = pos + 1; j < bids.size();="" ++j)="">
if (bids.at(j).title.compare(bids.at(min).title) < 0)="">
min = j;
}
}
if (min != pos) {
swap(bids.at(pos), bids.at(min));
}
}
}
1b.
case 3:
ticks = clock(); //Initialize the timer variable before loading bits
selectionSort(bids); //SelectionSort method call to load the bids
cout < bids.size()="">< "="" bids="" read"=""><>
//Used to calculate how much time has passed and display the result
ticks = clock() - ticks; //current clock minus the starting ticks
cout < "time:="" "="">< ticks="">< "="" clock="" ticks"=""><>
cout < "time:="" "="">< ticks="" *="" 1.0="" clocks_per_sec="">< "="" seconds"="">< endl;="">
2)int partition(vector& bids, int begin, int end) {
//set low and high equal to begin and end
int low = begin;
int high = end;
// pick the middle element as pivot point
int pivot = begin + (end - begin) / 2;
// while not done
bool done = false;
while (!done) {
// keep incrementing low index while bids[low] <>
while (bids.at(low).title.compare(bids.at(high).title) < 0)="">
++low;
}
// keep decrementing high index while bids[pivot] <>
while (bids.at(pivot).title.compare(bids.at(high).title) < 0)="">
--high;
}
/* If there are zero or one elements remaining,
all bids are partitioned. Return high */
if (low >= high) {
done = true;
}
// else swap the low and high bids (built in vector method)
// move low and high closer ++low, --high
else {
swap(bids.at(low), bids.at(high));
++low;
--high;
}
}
return high;
}
2b. case 4:
ticks = clock();
quickSort(bids, 0, bids.size() - 1);
cout < bids.size()="">< "="" bids="" read"=""><>
//Indicates the outcome of the elapsed time calculation
ticks = clock() - ticks; // current clock minus the starting ticks
cout < "time:="" "="">< ticks="">< "="" clock="" ticks"=""><>
cout < "time:="" "="">< ticks="" *="" 1.0="" clocks_per_sec="">< "="" seconds"=""><>
break;