Sorting and Searching

Write your question here.
Can somebody help me with this? i just cant figure it out
Here is an algorithm for selection sort which sorts n numbers in vector arr in non-decreasing order:
1
2
3
4
 for (i = 0; i < n-1; i++)
    for (j = i+1; j < n; j++)
        if (arr[i] > arr[j])
            swap(arr[i], arr[j])

Implement this algorithm in C++ and test its correctness. Write a main() function to
a. input a set of numbers from an input file into a vector,
b. call and pass the vector to selection sort, and
c. display the sorted numbers.
Use the following input file:
20
10
5
15
35
40
25
30
closed account (48T7M4Gy)
Do it in small stages.

Do part a) first and show us what you have.

Then do part b) You are given the algorithm so you have to put that in a function with the relevant parameters.

Then do part c) A no-brainer once you have the sorted vector?

Topic archived. No new replies allowed.