Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Templates. The code below contains a silly sort method. a) What is the time complexity? Why? b) Modify it so that it can sort

1. Templates. The code below contains a silly sort method.

a) What is the time complexity? Why?

b) Modify it so that it can sort "anything", for example strings. This means: make it a templated function.

c) In main(), introduce a 3 element array of these objects: struct bloodtype { char btype; bool posneg; }; and sort the array using ins_sort. You may need to modify the struct.

Your code does not need to print the resulting array.

void ins_sort(int arr[], int asize) { int tmp; int i,j; for (i = 1; i < asize; i++) { j = i; while (j > 0 && arr[j] < arr[j-1]) { tmp = arr[j]; arr[j] = arr[j-1]; arr[j-1] = tmp; j--; } } }

Note: I need my answer on C++ coding..please do it fast its urgent.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

How is program design being influenced by neuroscience research?

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago