I wouldn’t classify an insertion sort as anything anywhere near “advanced”.
In fact, I’d call it “beginner”.
I could even see this being your very first assignment. More on insertion sort:
http://www.cplusplus.com/faq/sequences/sequencing/sort-algorithms/insertion-sort/
You are in university now, so you aren’t going to have how to do everything handed to you. You’ll be expected to get C++ set up and running and be able to create and compile a simple program all on your own.
As
jonnin said, get a hello world program running.
1 2 3 4 5 6
|
#include <iostream>
int main()
{
std::cout << "Hello world!\n";
}
|
Once you get that to compile and execute, then you can work on adding an array of ten integers. You do not specify whether those integers are static, randomly-generated, or obtained from the user (which I recommend), but pick one and do it. Also figure out how to print them. Both the getting and the printing require a loop.
Once you get that far, then you can consider sorting the array. This will require two loops, one inside the other. Remember to think about the indexing of the array — very much like looping over the elements to print, except now you have a loop inside the outer loop that counts backwards, and you have to know how to swap elements in the array.
For example, given an array of integers:
1 2 4 5 6 7 4
To insert the last 4 into the correct spot, keep swapping until it is in the correct space:
1 2 4 5 6 4 7
1 2 4 5 4 6 7
1 2 4 4 5 6 7
If you need extra help, go to your university's help center. The computer lab often has someone who is willing to help you as well. If necessary, schedule time to talk to your professor during his office hours and he can direct you in the best way to catch up. (Swallow any pride or shame that may be keeping you from him; he doesn’t want you to fail the course any more than you do.)
Once you get some code working, post here as well. We will help you understand and fix it.
(We just aren’t very keen on doing your work for you.)