Can anyone help me wiht the prog.
arrange a 1D array in ascending order.
No need for the prog. code just explain me the logic.
Assuming you're supposed to write your own, rather than use the standard C++ sort
function, You'll need to implement a sort algorithm. a bubble sort or a selection sort should be fairly easy to write.
You'll find pseudocode for these here
http://en.wikipedia.org/wiki/Bubble_sort
http://en.wikipedia.org/wiki/Selection_sort
There are any number of ways to sort an array. Some of them are called bubble sort, qsort, sort(), merge sort, selection sort, etc. Each has their attractions and detractions. For arrays of relatively small size the bubble sort seems to be very popular with beginning programers because of the "simplicity" of implementation. The basic principle of bubble sort is to compare each element of the array, starting the index 0, with every other element in the array and swapping them if the desired criteria is satisfied.
my assingment says use selection sort duno what that is.
You can look it up using your favorite search engine. Basically, it means first find the smallest in the array and swap it with the element in the first position, then find the second smallest element and swap it with the element in the second position, and continue in this way until the entire array is sorted.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.