Question

Show the correctness of insertion sort. (Proof by induction)

Show the correctness of insertion sort. (Proof by induction)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Insertion sort:
proof by induction:
-
Base case:n=1//means only one element
since there is only one element, it is already sorted
hence true for base case
-
Induction step:
assume that the first n-1 elements are sorted in array after n-1 iterations(outer loop)
-
show that for nth element
now, to insert last nth element z into array, we will find it position to insert in between n-1 elements
by moving the bigger elements back one position, to place it in correct
which creates again sorted list of n elements
Hence insertion sort correctly sorts the data
hence proved by induction

Add a comment
Know the answer?
Add Answer to:
Show the correctness of insertion sort. (Proof by induction)
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT