English

In the following list containing integers, sort the list using Insertion sort algorithm. Also show the status of the list after each iteration. 15 -5 20 -10 10

Advertisements
Advertisements

Question

In the following list containing integers, sort the list using Insertion sort algorithm. Also show the status of the list after each iteration.

15     -5     20      -10     10

Short Answer
Advertisements

Solution

Initial list: [15, -5, 20, -10, 10]

Iteration Element inserted Status of list
1 -5 [-5, 15, 20, -10, 10]
2 20 [-5, 15, 20, -10, 10]
3 -10 [-10, -5, 15, 20, 10]
4 10 [-10, -5, 10, 15, 20]

Sorted list: [-10, -5, 10, 15, 20]

shaalaa.com
  Is there an error in this question or solution?
Chapter 5: Liner List Manipulation - EXERCISE [Page 104]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 5 Liner List Manipulation
EXERCISE | Q 11. | Page 104
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×