Lab13cpp Include Include Include Used Initialization Random Number Generator Using Namespa Q37060937

The goal of this assignment is to reinforce sorting algorithms in C++. Specifically, the lab is to implement the shell sort.

*********************lab13.cpp********************

#include <cstdlib>

#include <cassert>

#include <ctime> // used in initialization of randomnumber generator

using namespace std;

template <typenameT>

bool is_sorted (T* a, size_t size);

// precondition: a is not NULL

// returns: whether array a is sorted

template <typenameT>

void shell_sort (T* a, size_t size);

// precondition: a is not NULL

// postcondition: a is sorted in non-decreasingorder

int* create_array (size_t size);

// returns an array with size random integers

int main ()

{

size_t size = 1000;

int* a = create_array (size);

shell_sort (a, size);

assert (is_sorted (a, size));

delete a;

return EXIT_SUCCESS;

}

——–Please implement the shell sort

OR
OR

Leave a Comment

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