The Insertion Sort - C++ source code
By Sergey Skudaev
![]()
![]()
![]()
![]()
Precondition: The function accepts an unsorted array and integer size that is the size of the array.
Post condition: Sorted array
void insertionSort (
int array[], int
size)
{
int current = 1;
int temp;
int walker;
while (current <
size)
{
temp = array [current];
walker = current -1;
while (( walker >= 0 )&&(
temp < array [walker] ))
{
array[walker +1] = array[walker];
walker = walker -1;
}
array
[walker+1] = temp;
current = current +
1;
}
}
Did you find information useful?
Send to your friend a link to this page
Please rate the tutorial
Learn Visual Basic 6.0 [Kindle Edition] $1.99
How to Build Your Own Web Site from Scratch [Kindle Edition] $1.99
| Comments | |
|---|---|
- Home
- insertcpp
- Batch Files
- Java Properties
- Form Validation
- Display Image PHP
- Upload File PHP
- phpMyAdmin
- Environment Variables
- Delete Trojan horse
- Java Code Examples
- Learn Java
- Java, MS Access, MySQL
- Java Random Generator
- Thread Applet
- Sort Algorithms
- Computer Game
- Poet Applet
- More Code Examples
- Database Design
- Password Keeper
- MySQL and Excel
- Learn MySQL
- Learn SQL
- Learn PHP
- Learn C++
- Learn Visual Basic
- Web Site Tips
- User_Auth. Demo
- Using Twitter
- Advertise here
- Site map
- Registration
Web programming Tips