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.
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 (2024). Insertion Sort (https://www.mathworks.com/matlabcentral/fileexchange/27934-insertion-sort), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2010a
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
Find more on Shifting and Sorting Matrices in Help Center and MATLAB Answers
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |