Download presentation
1
Insertion Sort
2
Copyright © The McGraw-Hill Companies, Inc
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3
Example: Sorting problem
Input: A sequence of n numbers Output: A permutation of the input sequence such that The number that we wish to sort are known as the keys.
4
Pseudocode Insertion sort Insertion-sort(A) 1 for j 2 to length[A]
2 do keyA[j] Insert A[j] into the sorted sequence A[1..j-1] i j - 1 while i>0 and A[i]>key 6 do A[i+1] A[i] 7 i i - 1 A[i +1] key
5
Copyright © The McGraw-Hill Companies, Inc
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.