C Data Structure Write Solution Test 2 Problem 3 Uses Selection Sort Sort Items Vector Int Q37161865

c++, data structure

Write a solution to test 2 problem 3 that uses selectionsort to sort the items in the vector of integers.

#include <iostream>
#include <iterator>
#include <string>
#include <random>
using namespace std;

void insertionSort(int a[], int N)
{
   int sorted = 0;
   for (int sorted = 0; sorted < N – 1;++sorted)
   {
       int item_position = sorted +1;
       int item = a[item_position];
       while (item_position > 0&& a[item_position – 1] > item)
       {
           a[item_position]= a[item_position – 1];
          –item_position;
           copy(a, a + N,ostream_iterator<int>(cout, ” “)); cout << endl;
       }
       a[item_position] = item;
       copy(a, a + N,ostream_iterator<int>(cout,

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.