Showing posts with label Sorting. Show all posts
Showing posts with label Sorting. Show all posts

Programming : Sorting (Maximum/Minimum Sorting)

8/3/13

This sorting method called sequencing Maximum / minimum because it is based on the selection of elements of maximum / minimum as a base sequencing. The idea is to choose the elements of maximum / minimum element then swap it with the element farthest Array (element left end or right end).

Subsequently repeated in the same way for the remaining array elements with no longer includes elements that have been ordered array.

Suppose the array elements will be sorted ascending:
Step 1: Determine the maximum price in the L [1 .. N] maximum price Interchange with L [N]

Step 2: Determine the maximum price in the L [1 .. N-1] Interchange maximum price with L [N-1]

Step 3: Determine the maximum price in the L [1 .. N-2] Interchange maximum price with L [N-2]. .

Step N-1: Determine the maximum price in the L [1 .. 2] Interchange maximum price with L [2]

Remaining element is L [1] does not need to be sorted because it is the last element.
So at each step there is a sorting process of finding the maximum price checkers exchange process a two-element array. Number of sorting steps is N-1.

For example : 
Given an Array instance with N = 6 pieces Ascending elements not, this array will be sorted ascending. Element of the array is 25, 27, 10, 8, 76, 21

Programming : Sorting (Bubble Sort)

Ordering is the process of arranging a set of objects in a particular order or arrangement. The object can be an ascending sequence (Ascending) or decreased (Descending). The sorted data  has many advantages, among others:
1. Speed ​​up the search process
2. Can be easily determined maximum and minimum ordering process
There is a need to bring a variety of sorting methods which aim to obtain optimal sorting method.

Sorting algorithms which are widely recognized among others:
1. Bubble Sort (Sorting Bubble)
2. Insertion Sort (Sorting Insert)
3. Maximum / Minimum Sort
4. Heap Sort
5. Shell Sort
6. Quick Sort
7. Merge Sort
8. Radix Sort
9. Tree Sort


For all the sorting algorithms that will be discussed later using the type Array (Array),
which is defined as follows:
{Declaration}
Const NMaks = 100 //Maximum Number of elements {Array}
Type LarikInt = array [1 ... NMaks] of integer


In this post, we will discuss only three sorting methods, namely:
1. Ordering Bubbles (Bubble Sort) 
Ordering bubble inspired by soap bubbles are above the water surface. Because soaps are lighter specific gravity than water density, it will always be soap bubbles floating on the surface. The principle of flotation is used in bubble sort. Array elements are the most precious little "float", meaning lift up (or to the left end of the array) through a process of exchange, if it will do sorting enlarged, if ordering smaller otherwise.

 

Tags