Question: Write the code for mode A using std::partial_sort() to place the k smallest numbers in order at the front of the vector list; Write the

Write the code for mode A using std::partial_sort() to place the k smallest numbers in order at the front of the vector list; Write the code for mode B which uses std::make_heap(),a loop based on std::pop_heap(),and std::reverse() to place the k largest numbers in order at the front of the vector list; Write the code for mode C which, based on the code for mode B, produces output similar to mode A with the k smallest numbers placed in order at the front of the vector list.
#include <...> using namespace std; int main(int argc, char *argv[]) { if (argc != 3){ cout A; int din; while (cin >> din) A.push_back(din); int N = (int)A.size(); if (mode == 'A') { // use std::partial_sort() } else if (mode == 'B') { // use std::make_heap(), loop w/std::pop_heap() and std::reverse() } else if (mode == 'C') { // modify the code from mode B work like mode A } for (int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
