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.

Recommended Answers

All 4 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.