Integer Array that can be sorted in different kinds

Our professor haven't taught us about these parts yet the only clue we got is that it uses array.
Any help would be appreciated.

Create a program that would accept an array of integers and contains the following functions:

A. Sort in ascending order- user defined function that returns an array of 10 entered integers in ascending order

B. Sort in descending order- user defined function that returns an array of 10 entered integers in descending order

C. Get_indexof- user defined function that returns the index of the integer being searched from the entered array of 10 integers

D. Replace- user defined function that replaces the integer specified to be replaced from the array of 10 integers
c++ has built in sorting, but usually these problems are to re-invent the wheel and learn how to do it yourself. There are a bunch of nifty sorting algorithms out there, my favorite personally is shellshort which is just a handful of lines of code yet performs as well as anything else up to many millions of entries, it is slowly passed by more complex algorithms if dealing with big data, but if you had big data, .. use the built in one :) I advise you to research it, as it has a very unique profile ... its computational complexity varies based off which sequence you choose to use for the presorting. I think the top end is O(N ^((c+1)/c) ) where C can vary but is generally less than 10. Its a fun study.

You can find code for it, or pseudo code, online easily. Give it a try, and ask if you get stuck trying to make it work.

Once you get it working for A) figure out the logic to reverse the comparison and swap logic for B). C and D make use of sorted data, so those can wait.



Topic archived. No new replies allowed.