The Selection Sort Algorithms - C++ source code.
![]()
![]()
Precondition: the function accepts an unsorted array and integer size that is the size of the array.
Post condition: Sorted array
The function looks for the smallest number and moves it to the head of the array
void SelectiveSort ( int
size, int array [] )
{
int current
= 0;
while ( current <
size )
{
int smallest = current;
int walker = current +1;
while ( walker < size )
{
if ( array [walker] < array [smallest] )
smallest = walker;
walker ++;
}
exchange ( array, current, smallest );
current ++;
}
}
void exchange (int array[], int a, int b)
{
int temp=array[a];
array[a]=array[b];
array[b]=temp;
}
Did you find information useful?
Send to your friend a link to this page
If you like this page click +1 button.
Please rate the tutorial
How to Build Your Own Web Site from Scratch [Kindle Edition] $2.99
Earn Money on Internet as an Affiliate [Kindle Edition] $0.99
| Comments | |
|---|---|
- Home
- selsortcpp
- Batch Files
- Java Properties
- Form Validation
- Display Image PHP
- Upload File PHP
- phpMyAdmin
- Environment Variables
- Delete Trojan horse
- C ++ Code Examples
- Start C++
- C ++ Continue
- C ++ Pointer
- Variable Scope
- Linked List
- Bubble Sort
- Two Bubble Sort
- Insertion Sort
- Selection Sort
- Two Selection Sort
- Database Design
- Password Keeper
- MySQL and Excel
- Learn MySQL
- Learn PHP
- Learn Visual Basic
- Learn Java
- Web Site Tips
- User_Auth. Demo
- Merge Bin Sort
- Advertise here
- Using Twitter
- Site map
- Registration
Web programming Tips