File Exchange

image thumbnail

Insertion Sort

version 1.0.0.0 (1.22 KB) by x yz
Insertion sort is a simple sorting algorithm in which the sorted array is built one entry at a time.

1 Download

Updated 17 Jun 2010

View License

For example enter a sequence: 7 9 8 3 1

Algorithm will follow the steps as follows:

original sequence: 7 9 8 3 1
Step 1: 7 9 8 3 1
Step 2: 7 8 9 3 1
Step 3: 7 8 9 3 1
Step 4: 7 8 3 9 1
Step 5: 7 3 8 9 1
Step 6: 3 7 8 9 1
Step 7: 3 7 8 1 9
Step 8: 3 7 1 8 9
Step 9: 3 1 7 8 9
Step 10: 1 3 7 8 9
Answer: 1 3 7 8 9

Cite As

x yz (2021). Insertion Sort (https://www.mathworks.com/matlabcentral/fileexchange/27934-insertion-sort), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Rob Campbell

?

Duane Hanselman

Is this a homework solution or does the author not know about the function sort or does the author think that this function is better in some way than the built in function sort?

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!